コード例 #1
0
class TestImageRepositoriesType(TestCase):
    def setUp(self):
        self.param_type = ImageRepositoriesType()
        self.mock_param = Mock(opts=["--image-repositories"])

    @parameterized.expand(
        [
            # Just a string
            ("some string"),
            # Too many equals
            ("a=b=c=d"),
            # Almost an URI, but no dkr
            ("Hello=123456789012.us-east-1.amazonaws.com/test1"),
            # Almost an URI, but no repo-name
            ("Hello=123456789012.us-east-1.amazonaws.com/"),
            # Almost an URI, but no region name
            ("Hello=123456789012.dkr.ecr.amazonaws.com/test1"),
            # Almost an URI, but no service name
            ("Hello=123456789012.dkr.amazonaws.com/test1"),
        ]
    )
    def test_must_fail_on_invalid_format(self, input):
        self.param_type.fail = Mock()
        with self.assertRaises(BadParameter):
            self.param_type.convert(input, self.mock_param, Mock())

    @parameterized.expand(
        [
            (
                "HelloWorld=123456789012.dkr.ecr.us-east-1.amazonaws.com/test1",
                {"HelloWorld": "123456789012.dkr.ecr.us-east-1.amazonaws.com/test1"},
            ),
            (
                "HelloWorld=123456789012.dkr.ecr.cn-north-1.amazonaws.com.cn/test1",
                {"HelloWorld": "123456789012.dkr.ecr.cn-north-1.amazonaws.com.cn/test1"},
            ),
        ]
    )
    def test_successful_parsing(self, input, expected):
        result = self.param_type.convert(input, self.mock_param, Mock())
        self.assertEqual(result, expected, msg="Failed with Input = " + str(input))
コード例 #2
0
    help=
    "The name of the S3 bucket where this command uploads the artifacts that are referenced in your template.",
)
@click.option(
    "--image-repository",
    callback=partial(artifact_callback, artifact=IMAGE),
    type=ImageRepositoryType(),
    required=False,
    help=
    "ECR repo uri where this command uploads the image artifacts that are referenced in your template.",
)
@click.option(
    "--image-repositories",
    multiple=True,
    callback=image_repositories_callback,
    type=ImageRepositoriesType(),
    required=False,
    help=
    "Specify mapping of Function Logical ID to ECR Repo uri, of the form Function_Logical_ID=ECR_Repo_Uri."
    "This option can be specified multiple times.",
)
@click.option(
    "--s3-prefix",
    required=False,
    help="A prefix name that the command adds to the artifacts "
    "name when it uploads them to the S3 bucket. The prefix name is a "
    "path name (folder name) for the S3 bucket.",
)
@click.option(
    "--kms-key-id",
    required=False,
コード例 #3
0
 def setUp(self):
     self.param_type = ImageRepositoriesType()
     self.mock_param = Mock(opts=["--image-repositories"])