Пример #1
0
    def test_wiki_with_fake_origin(self, mock_get):

        fixture = fixture_setup.FakePartsWikiOrigin()
        self.useFixture(fixture)
        origin_url = fixture.fake_parts_wiki_origin_fixture.url

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: {origin_url}
description: example
parts: [somepart]
""".format(origin_url=origin_url))

        origin_dir = os.path.join(BASE_DIR, _encode_origin(origin_url))
        os.makedirs(origin_dir, exist_ok=True)

        # Create a fake snapcraft.yaml for _get_origin_data() to parse
        with open(os.path.join(origin_dir, 'snapcraft.yaml'), 'w') as fp:
            text = requests.get(origin_url).text
            fp.write(text)

        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(1, _get_part_list_count())
        part = _get_part('somepart')
        self.assertTrue(part)
Пример #2
0
    def test_wiki_with_fake_origin_with_bad_snapcraft_yaml(self, mock_get):

        fixture = fixture_setup.FakePartsWikiOrigin()
        self.useFixture(fixture)
        origin_url = fixture.fake_parts_wiki_origin_fixture.url

        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: {origin_url}
description: example
parts: [somepart]
""".format(origin_url=origin_url))

        origin_dir = os.path.join(BASE_DIR, _encode_origin(origin_url))
        os.makedirs(origin_dir, exist_ok=True)

        # Create a fake snapcraft.yaml for _get_origin_data() to parse
        with open(os.path.join(origin_dir, 'snapcraft.yaml'), 'w') as fp:
            fp.write("bad yaml is : bad :yaml:::")

        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(0, _get_part_list_count())

        self.assertTrue('Invalid wiki entry' in fake_logger.output,
                        'Missing invalid wiki entry info in output')
Пример #3
0
    def test_missing_snapcraft_yaml_without_debug(self, mock_get):

        fixture = fixture_setup.FakePartsWikiOrigin()
        self.useFixture(fixture)
        origin_url = fixture.fake_parts_wiki_origin_fixture.url

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: {origin_url}
description: example
parts: [somepart]
""".format(origin_url=origin_url))

        main(['--index', TEST_OUTPUT_PATH])
        self.assertEqual(0, _get_part_list_count())
Пример #4
0
    def test_missing_snapcraft_yaml(self, mock_get):

        fixture = fixture_setup.FakePartsWikiOrigin()
        self.useFixture(fixture)
        origin_url = fixture.fake_parts_wiki_origin_fixture.url

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: {origin_url}
description: example
project-part: 'somepart'
""".format(origin_url=origin_url))

        self.assertRaises(MissingSnapcraftYAMLError, main,
                          ['--debug', '--index', TEST_OUTPUT_PATH])
Пример #5
0
    def test_missing_snapcraft_yaml(self, mock_get):

        fixture = fixture_setup.FakePartsWikiOrigin()
        self.useFixture(fixture)
        origin_url = fixture.fake_parts_wiki_origin_fixture.url

        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: {origin_url}
description: example
parts: [somepart]
""".format(origin_url=origin_url))

        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(0, _get_part_list_count())

        self.assertTrue('Invalid wiki entry' in fake_logger.output,
                        'Missing invalid wiki entry info in output')