Finish porting from nose to pytest.
This commit is contained in:
parent
77dc60ea97
commit
ea489bce6c
72 changed files with 1289 additions and 1280 deletions
|
|
@ -604,7 +604,7 @@ def test_create_certificate_validation():
|
|||
client = boto3.client("iot", region_name="us-east-1")
|
||||
cert = client.create_keys_and_certificate(setAsActive=False)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.register_certificate(
|
||||
certificatePem=cert["certificatePem"], setAsActive=False
|
||||
)
|
||||
|
|
@ -612,7 +612,7 @@ def test_create_certificate_validation():
|
|||
"The certificate is already provisioned or registered"
|
||||
)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.register_certificate_without_ca(
|
||||
certificatePem=cert["certificatePem"], status="ACTIVE"
|
||||
)
|
||||
|
|
@ -645,7 +645,7 @@ def test_delete_policy_validation():
|
|||
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.delete_policy(policyName=policy_name)
|
||||
e.exception.response["Error"]["Message"].should.contain(
|
||||
e.value.response["Error"]["Message"].should.contain(
|
||||
"The policy cannot be deleted as the policy is attached to one or more principals (name=%s)"
|
||||
% policy_name
|
||||
)
|
||||
|
|
@ -686,7 +686,7 @@ def test_delete_certificate_validation():
|
|||
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.delete_certificate(certificateId=cert_id)
|
||||
e.exception.response["Error"]["Message"].should.contain(
|
||||
e.value.response["Error"]["Message"].should.contain(
|
||||
"Certificate must be deactivated (not ACTIVE) before deletion."
|
||||
)
|
||||
res = client.list_certificates()
|
||||
|
|
@ -695,7 +695,7 @@ def test_delete_certificate_validation():
|
|||
client.update_certificate(certificateId=cert_id, newStatus="REVOKED")
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.delete_certificate(certificateId=cert_id)
|
||||
e.exception.response["Error"]["Message"].should.contain(
|
||||
e.value.response["Error"]["Message"].should.contain(
|
||||
"Things must be detached before deletion (arn: %s)" % cert_arn
|
||||
)
|
||||
res = client.list_certificates()
|
||||
|
|
@ -704,7 +704,7 @@ def test_delete_certificate_validation():
|
|||
client.detach_thing_principal(thingName=thing_name, principal=cert_arn)
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.delete_certificate(certificateId=cert_id)
|
||||
e.exception.response["Error"]["Message"].should.contain(
|
||||
e.value.response["Error"]["Message"].should.contain(
|
||||
"Certificate policies must be detached before deletion (arn: %s)" % cert_arn
|
||||
)
|
||||
res = client.list_certificates()
|
||||
|
|
@ -800,7 +800,7 @@ def test_principal_policy():
|
|||
res.should.have.key("principals").which.should.have.length_of(0)
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.detach_policy(policyName=policy_name, target=cert_arn)
|
||||
e.exception.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
||||
e.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
||||
|
||||
|
||||
@mock_iot
|
||||
|
|
@ -857,11 +857,11 @@ def test_principal_thing():
|
|||
res = client.list_thing_principals(thingName=thing_name)
|
||||
res.should.have.key("principals").which.should.have.length_of(0)
|
||||
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.list_thing_principals(thingName="xxx")
|
||||
|
||||
e.exception.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
||||
e.exception.response["Error"]["Message"].should.equal(
|
||||
e.value.response["Error"]["Code"].should.equal("ResourceNotFoundException")
|
||||
e.value.response["Error"]["Message"].should.equal(
|
||||
"Failed to list principals for thing xxx because the thing does not exist in your account"
|
||||
)
|
||||
|
||||
|
|
@ -937,9 +937,9 @@ class TestListThingGroup:
|
|||
resp = client.list_thing_groups(parentGroup=self.group_name_1b)
|
||||
resp.should.have.key("thingGroups")
|
||||
resp["thingGroups"].should.have.length_of(0)
|
||||
with assert_raises(ClientError) as e:
|
||||
with pytest.raises(ClientError) as e:
|
||||
client.list_thing_groups(parentGroup="inexistant-group-name")
|
||||
e.exception.response["Error"]["Code"].should.equal(
|
||||
e.value.response["Error"]["Code"].should.equal(
|
||||
"ResourceNotFoundException"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue