Пример #1
0
 def test_template_write(self):
     mock_temp = Mock("taskcat._cfn.template.Template", autospec=True)()
     mock_temp.raw_template = "some-template-data"
     au_template = Template(underlying=mock_temp)
     au_template._ls = "some-other-data"
     au_template.write()
     mock_temp.write.assert_called_once()
Пример #2
0
 def test_template_set_codename_ami_no_region(self):
     tc_template = self.create_ephemeral_template_object()["taskcat-json"]
     au_template = Template(underlying=tc_template, regions_with_creds=[])
     actual = au_template.set_codename_ami(
         "AMZNLINUXHVM", "us-west-1", "slkdfjskldfj"
     )
     self.assertFalse(actual)
Пример #3
0
 def test_template_write(self):
     mock_temp = unittest.mock.Mock(
         "taskcat._cfn.template.Template", autospec=True
     )()
     mock_temp.raw_template = "some-template-data"
     au_template = Template(underlying=mock_temp, regions_with_creds=["us-east-1"])
     au_template._ls = "some-other-data"
     au_template.write()
     mock_temp.write.assert_called_once()
Пример #4
0
 def test_build_codenames(self):
     example_tc_template = self.create_ephemeral_template_object()
     au_template = Template(example_tc_template["taskcat-json"], ["us-east-1"])
     example_config_obj = AUConfig
     example_config_obj.raw_dict = {
         "global": {
             "AMIs": {
                 "AMZNLINUXHVM": {
                     "name": "amzn-ami-hvm-????.??.?.*-x86_64-gp2",
                     "owner-alias": "amazon",
                 }
             }
         }
     }
     expected = [
         RegionalCodename(
             region="us-east-1",
             cn="AMZNLINUXHVM",
             filters=[
                 EC2FilterValue("name", ["amzn-ami-hvm-????.??.?.*-x86_64-gp2"]),
                 EC2FilterValue("owner-alias", ["amazon"]),
                 EC2FilterValue("state", ["available"]),
             ],
         )
     ]
     actual = build_codenames(au_template, example_config_obj)
     _mocked_dt = datetime.now()
     for r1 in expected:
         r1._creation_dt = _mocked_dt
     for r2 in actual:
         r2._creation_dt = _mocked_dt
     self.assertEqual(expected, actual)
Пример #5
0
 def test_template_set_codename_ami(self):
     tc_template = self.create_ephemeral_template_object()["taskcat-json"]
     au_template = Template(underlying=tc_template)
     actual = au_template.set_codename_ami("AMZNLINUXHVM", "us-east-1",
                                           "slkdfjskldfj")
     self.assertTrue(actual)
Пример #6
0
 def test_invalid_region_exception(self):
     example_tc_template = self.create_ephemeral_template_object()
     au_template = Template(example_tc_template["taskcat-json"], ["us-east-1"])
     self.assertEqual(au_template.regions_without_creds, {"us-east-2"})
     self.assertEqual(au_template.region_names, {"us-east-1"})