Techdebt: Replace sure with regular asserts in ECR (#6530)
This commit is contained in:
parent
79bd7c5bae
commit
58ad693c42
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,8 @@
|
|||||||
import copy
|
import copy
|
||||||
from string import Template
|
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
import json
|
import json
|
||||||
from moto import mock_cloudformation, mock_ecr
|
from moto import mock_cloudformation, mock_ecr
|
||||||
import sure # noqa # pylint: disable=unused-import
|
from string import Template
|
||||||
|
|
||||||
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
||||||
|
|
||||||
@ -45,12 +43,12 @@ def test_create_repository():
|
|||||||
# then
|
# then
|
||||||
repo_arn = f"arn:aws:ecr:eu-central-1:{ACCOUNT_ID}:repository/{name}"
|
repo_arn = f"arn:aws:ecr:eu-central-1:{ACCOUNT_ID}:repository/{name}"
|
||||||
stack = cfn_client.describe_stacks(StackName=stack_name)["Stacks"][0]
|
stack = cfn_client.describe_stacks(StackName=stack_name)["Stacks"][0]
|
||||||
stack["Outputs"][0]["OutputValue"].should.equal(repo_arn)
|
assert stack["Outputs"][0]["OutputValue"] == repo_arn
|
||||||
|
|
||||||
ecr_client = boto3.client("ecr", region_name="eu-central-1")
|
ecr_client = boto3.client("ecr", region_name="eu-central-1")
|
||||||
response = ecr_client.describe_repositories(repositoryNames=[name])
|
response = ecr_client.describe_repositories(repositoryNames=[name])
|
||||||
|
|
||||||
response["repositories"][0]["repositoryArn"].should.equal(repo_arn)
|
assert response["repositories"][0]["repositoryArn"] == repo_arn
|
||||||
|
|
||||||
|
|
||||||
@mock_ecr
|
@mock_ecr
|
||||||
@ -78,10 +76,11 @@ def test_update_repository():
|
|||||||
response = ecr_client.describe_repositories(repositoryNames=[name])
|
response = ecr_client.describe_repositories(repositoryNames=[name])
|
||||||
|
|
||||||
repo = response["repositories"][0]
|
repo = response["repositories"][0]
|
||||||
repo["repositoryArn"].should.equal(
|
assert (
|
||||||
f"arn:aws:ecr:eu-central-1:{ACCOUNT_ID}:repository/{name}"
|
repo["repositoryArn"]
|
||||||
|
== f"arn:aws:ecr:eu-central-1:{ACCOUNT_ID}:repository/{name}"
|
||||||
)
|
)
|
||||||
repo["imageTagMutability"].should.equal("IMMUTABLE")
|
assert repo["imageTagMutability"] == "IMMUTABLE"
|
||||||
|
|
||||||
|
|
||||||
@mock_ecr
|
@mock_ecr
|
||||||
@ -100,4 +99,4 @@ def test_delete_repository():
|
|||||||
# then
|
# then
|
||||||
ecr_client = boto3.client("ecr", region_name="eu-central-1")
|
ecr_client = boto3.client("ecr", region_name="eu-central-1")
|
||||||
response = ecr_client.describe_repositories()["repositories"]
|
response = ecr_client.describe_repositories()["repositories"]
|
||||||
response.should.have.length_of(0)
|
assert len(response) == 0
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sure # noqa # pylint: disable=unused-import
|
|
||||||
|
|
||||||
from moto.ecr.exceptions import InvalidParameterException
|
from moto.ecr.exceptions import InvalidParameterException
|
||||||
from moto.ecr.policy_validation import EcrLifecyclePolicyValidator
|
from moto.ecr.policy_validation import EcrLifecyclePolicyValidator
|
||||||
@ -70,12 +69,11 @@ def test_validate_error_parse(policy):
|
|||||||
|
|
||||||
# then
|
# then
|
||||||
ex = e.value
|
ex = e.value
|
||||||
ex.code.should.equal(400)
|
assert ex.code == 400
|
||||||
ex.error_type.should.equal("InvalidParameterException")
|
assert ex.error_type == "InvalidParameterException"
|
||||||
ex.message.should.equal(
|
assert (
|
||||||
"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: "
|
ex.message
|
||||||
"'Lifecycle policy validation failure: "
|
== "Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: 'Lifecycle policy validation failure: Could not map policyString into LifecyclePolicy.'"
|
||||||
"Could not map policyString into LifecyclePolicy.'"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -108,12 +106,11 @@ def test_validate_error_extract_rules(policy):
|
|||||||
|
|
||||||
# then
|
# then
|
||||||
ex = e.value
|
ex = e.value
|
||||||
ex.code.should.equal(400)
|
assert ex.code == 400
|
||||||
ex.error_type.should.equal("InvalidParameterException")
|
assert ex.error_type == "InvalidParameterException"
|
||||||
ex.message.should.equal(
|
assert (
|
||||||
"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: "
|
ex.message
|
||||||
"'Lifecycle policy validation failure: "
|
== "Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: 'Lifecycle policy validation failure: object has missing required properties ([\"rules\"])'"
|
||||||
'object has missing required properties (["rules"])\''
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -128,9 +125,9 @@ def test_validate_error_rule_type(rule):
|
|||||||
|
|
||||||
# then
|
# then
|
||||||
ex = e.value
|
ex = e.value
|
||||||
ex.code.should.equal(400)
|
assert ex.code == 400
|
||||||
ex.error_type.should.equal("InvalidParameterException")
|
assert ex.error_type == "InvalidParameterException"
|
||||||
ex.message.should.equal(
|
assert ex.message == (
|
||||||
"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: "
|
"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: "
|
||||||
"'Lifecycle policy validation failure: "
|
"'Lifecycle policy validation failure: "
|
||||||
f'instance type ({type(rule)}) does not match any allowed primitive type (allowed: ["object"])\''
|
f'instance type ({type(rule)}) does not match any allowed primitive type (allowed: ["object"])\''
|
||||||
@ -198,16 +195,11 @@ def test_validate_error_rule_properties(rule, error_msg):
|
|||||||
|
|
||||||
# then
|
# then
|
||||||
ex = e.value
|
ex = e.value
|
||||||
ex.code.should.equal(400)
|
assert ex.code == 400
|
||||||
ex.error_type.should.equal("InvalidParameterException")
|
assert ex.error_type == "InvalidParameterException"
|
||||||
ex.message.should.equal(
|
assert (
|
||||||
"".join(
|
ex.message
|
||||||
[
|
== f"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: 'Lifecycle policy validation failure: {error_msg}"
|
||||||
"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: "
|
|
||||||
"'Lifecycle policy validation failure: ",
|
|
||||||
error_msg,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -258,16 +250,11 @@ def test_validate_error_action_properties(action, error_msg):
|
|||||||
|
|
||||||
# then
|
# then
|
||||||
ex = e.value
|
ex = e.value
|
||||||
ex.code.should.equal(400)
|
assert ex.code == 400
|
||||||
ex.error_type.should.equal("InvalidParameterException")
|
assert ex.error_type == "InvalidParameterException"
|
||||||
ex.message.should.equal(
|
assert (
|
||||||
"".join(
|
ex.message
|
||||||
[
|
== f"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: 'Lifecycle policy validation failure: {error_msg}"
|
||||||
"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: "
|
|
||||||
"'Lifecycle policy validation failure: ",
|
|
||||||
error_msg,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -382,14 +369,9 @@ def test_validate_error_selection_properties(selection, error_msg):
|
|||||||
|
|
||||||
# then
|
# then
|
||||||
ex = e.value
|
ex = e.value
|
||||||
ex.code.should.equal(400)
|
assert ex.code == 400
|
||||||
ex.error_type.should.equal("InvalidParameterException")
|
assert ex.error_type == "InvalidParameterException"
|
||||||
ex.message.should.equal(
|
assert (
|
||||||
"".join(
|
ex.message
|
||||||
[
|
== f"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: 'Lifecycle policy validation failure: {error_msg}"
|
||||||
"Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: "
|
|
||||||
"'Lifecycle policy validation failure: ",
|
|
||||||
error_msg,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user