示例#1
0
class TestMetaMainHasInfo(unittest.TestCase):
    collection = RulesCollection()
    collection.register(MetaMainHasInfoRule())

    def setUp(self):
        self.runner = RunFromText(self.collection)

    def test_no_galaxy_info(self):
        results = self.runner.run_role_meta_main(NO_GALAXY_INFO)
        assert len(results) == 1
        self.assertIn("No 'galaxy_info' found", str(results))

    def test_missing_info(self):
        results = self.runner.run_role_meta_main(MISSING_INFO)
        assert len(results) == 3
        self.assertIn("Role info should contain author", str(results))
        self.assertIn("Role info should contain min_ansible_version",
                      str(results))
        self.assertIn("Platform should contain name", str(results))

    def test_bad_types(self):
        results = self.runner.run_role_meta_main(BAD_TYPES)
        assert len(results) == 3
        self.assertIn("author should be a string", str(results))
        self.assertIn("description should be a string", str(results))
        self.assertIn("Platforms should be a list of dictionaries",
                      str(results))

    def test_platform_list_of_str(self):
        results = self.runner.run_role_meta_main(PLATFORMS_LIST_OF_STR)
        assert len(results) == 1
        self.assertIn("Platforms should be a list of dictionaries",
                      str(results))
class TestMetaChangeFromDefault(unittest.TestCase):
    collection = RulesCollection()
    collection.register(MetaChangeFromDefaultRule())

    def setUp(self):
        self.runner = RunFromText(self.collection)

    def test_default_galaxy_info(self):
        results = self.runner.run_role_meta_main(DEFAULT_GALAXY_INFO)
        self.assertIn("Should change default metadata: author", str(results))
        self.assertIn("Should change default metadata: description", str(results))
        self.assertIn("Should change default metadata: company", str(results))
        self.assertIn("Should change default metadata: license", str(results))
示例#3
0
class TestMetaVideoLinks(unittest.TestCase):
    collection = RulesCollection()
    collection.register(MetaVideoLinksRule())

    def setUp(self):
        self.runner = RunFromText(self.collection)

    def test_video_links(self):
        results = self.runner.run_role_meta_main(META_VIDEO_LINKS)
        self.assertIn("Expected item in 'video_links' to be a dictionary", str(results))
        self.assertIn(
            "'video_links' to contain only keys 'url' and 'title'", str(results)
        )
        self.assertIn("URL format 'www.myvid.com/vid' is not recognized", str(results))
示例#4
0
class TestMetaTagValid(unittest.TestCase):
    collection = RulesCollection()
    collection.register(MetaTagValidRule())

    def setUp(self):
        self.runner = RunFromText(self.collection)

    def test_valid_tag_rule(self):
        results = self.runner.run_role_meta_main(META_TAG_VALID)
        self.assertIn("Use 'galaxy_tags' rather than 'categories'",
                      str(results))
        self.assertIn("Expected 'categories' to be a list", str(results))
        self.assertIn("invalid: 'my s q l'", str(results))
        self.assertIn("invalid: 'MYTAG'", str(results))
def test_role_meta(default_text_runner: RunFromText) -> None:
    results = default_text_runner.run_role_meta_main(ROLE_META)
    assert len(results) == 0