Exemple #1
0
    def test_output_parameter(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }

        filename = "parts.yaml"

        main(["--debug", "--index", TEST_OUTPUT_PATH, "--output", filename])

        self.assertThat(_get_part_list_count(filename), Equals(1))
        self.assertTrue(os.path.exists(filename))
Exemple #2
0
    def test_carriage_returns(self, mock_get_origin_data):
        """Test carriage returns in the wiki."""

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

        _create_example_output(
            """\r
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main\r
parts: [main]\r
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main duplicate
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        part = _get_part("main")
        self.assertThat(part["description"], Equals("example main"))

        self.assertThat(_get_part_list_count(), Equals(1))
Exemple #3
0
    def test_output_parameter(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }

        filename = 'parts.yaml'

        main(['--debug', '--index', TEST_OUTPUT_PATH, '--output', filename])

        self.assertEqual(1, _get_part_list_count(filename))
        self.assertTrue(os.path.exists(filename))
Exemple #4
0
    def test_source_with_local_source_subdir_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with a source with a local source-subdir part."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": ".",
                    "source-subdir": "local",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(1))
        part = _get_part("main")
        self.assertNotEqual(".", part["source"])
        self.assertThat(part["source-subdir"], Equals("local"))
        self.assertThat(len(part.keys()), Equals(6))
Exemple #5
0
    def test_carriage_returns(self, mock_get_origin_data):
        """Test carriage returns in the wiki."""

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

        _create_example_output("""\r
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main\r
parts: [main]\r
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main duplicate
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        part = _get_part('main')
        self.assertEqual('example main', part['description'])

        self.assertEqual(1, _get_part_list_count())
Exemple #6
0
    def test_multiple_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: ['main', 'subpart']
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                    'after': ['subpart'],
                },
                'subpart': {
                    'source': 'lp:somethingelse',
                    'plugin': 'copy',
                    'files': ['subfile2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.assertEqual(2, _get_part_list_count())
Exemple #7
0
    def test_descriptions_get_block_quotes(self, mock_get_origin_data):
        output = """
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: |
  example

  Usage:
    blahblahblah
parts: [main]
"""
        _create_example_output(output)
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        with open('snap-parts.yaml') as fp:
            data = fp.read()
            self.assertNotIn('description: "', data)
            self.assertIn('description: |', data)
        self.assertEqual(1, _get_part_list_count())
Exemple #8
0
    def test_wiki_interactions_with_fake_with_slashes(self, mock_get_origin_data):

        fixture = fixture_setup.FakePartsWikiWithSlashes()
        self.useFixture(fixture)

        mock_get_origin_data.return_value = {
            "parts": {
                "curl/a": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
                "curl-a": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
            }
        }
        main(["--debug", "--index", fixture.fake_parts_wiki_with_slashes_fixture.url])
        self.assertThat(_get_part_list_count(), Equals(2))

        part1 = _get_part("curl/a")
        self.assertTrue(part1)

        part2 = _get_part("curl-a")
        self.assertTrue(part2)
Exemple #9
0
    def test_wiki_interactions_with_fake_with_slashes(
            self, mock_get_origin_data):

        fixture = fixture_setup.FakePartsWikiWithSlashes()
        self.useFixture(fixture)

        mock_get_origin_data.return_value = {
            'parts': {
                'curl/a': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
                'curl-a': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index',
              fixture.fake_parts_wiki_with_slashes_fixture.url])
        self.assertEqual(2, _get_part_list_count())

        part1 = _get_part('curl/a')
        self.assertTrue(part1)

        part2 = _get_part('curl-a')
        self.assertTrue(part2)
Exemple #10
0
    def test_missing_snapcraft_yaml(self):

        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.assertThat(_get_part_list_count(), Equals(0))

        self.assertTrue(
            "1 wiki errors found" in fake_logger.output,
            "Missing invalid wiki entry info in output",
        )
Exemple #11
0
    def test_main_nested_parts_invalid(self, mock_get_origin_data):
        """Ensure that we fail if there are dependent parts that
        are not included in the wiki's 'parts' section."""

        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                    'after': ['part1'],
                },
                'part1': {
                    'source': 'lp:somethingelse1',
                    'plugin': 'copy',
                    'files': ['subfile1'],
                    'after': ['part2'],
                },
                'part2': {
                    'source': 'lp:somethingelse2',
                    'plugin': 'copy',
                    'files': ['subfile2'],
                },
            }
        }
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main, part1]
""")
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(0, _get_part_list_count())
Exemple #12
0
    def test_wiki_with_fake_origin_with_bad_snapcraft_yaml(self):

        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(parser._get_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')
Exemple #13
0
    def test_main_slash_warning(self, mock_get_origin_data):
        fake_logger = fixtures.FakeLogger(level=logging.WARN)
        self.useFixture(fake_logger)

        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main/a]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main/a': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(1, _get_part_list_count())

        m = 'DEPRECATED: Found a "/" in the name of the {!r} part'.format(
            'main/a')
        self.assertTrue(m in fake_logger.output,
                        'Missing slash deprecation warning in output')
Exemple #14
0
 def test_main_valid_with_default_index(self, mock_urlopen):
     class FakeResponse:
         def read(self):
             return b''
     mock_urlopen.return_value = FakeResponse()
     main(['--debug'])
     self.assertEqual(0, _get_part_list_count())
Exemple #15
0
    def test_wiki_with_fake_origin(self):

        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(parser._get_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)
Exemple #16
0
    def test_n_documents(self, mock_get_origin_data):
        """Test 2 wiki entries."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main2]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
                "main2": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(2))
Exemple #17
0
    def test_remote_after_parts_unordered(self, mock_get_origin_data):
        _create_example_output("""
---
maintainer: Marco Trevisan <*****@*****.**>
origin: lp:snapcraft-parser-example
description: parent part that depends on child
parts: [parent]
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example part on which parent depends on
parts: [child]
""")
        parts = OrderedDict()

        parent_part = OrderedDict()
        parent_part['description'] = 'example part on which parent depends on'
        parent_part['maintainer'] = 'Marco Trevisan <*****@*****.**>'
        parent_part['plugin'] = 'dump'
        parent_part['source'] = 'lp:project'
        parent_part['after'] = ['child']
        parts['parent'] = parent_part

        child_part = OrderedDict()
        child_part['description'] = 'parent part that depends on child'
        child_part['maintainer'] = 'John Doe <*****@*****.**>'
        child_part['plugin'] = 'dump'
        child_part['source'] = 'lp:project'
        parts['child'] = child_part

        mock_get_origin_data.return_value = {
            'parts': parts,
        }
        main(['--index', TEST_OUTPUT_PATH])
        self.assertEqual(2, _get_part_list_count())
Exemple #18
0
    def test_descriptions_get_block_quotes(self, mock_get_origin_data):
        output = """
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: |
  example

  Usage:
    blahblahblah
parts: [main]
"""
        _create_example_output(output)
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])
        with open("snap-parts.yaml") as fp:
            data = fp.read()
            self.assertNotIn('description: "', data)
            self.assertIn("description: |", data)
        self.assertThat(_get_part_list_count(), Equals(1))
Exemple #19
0
    def test_main_slash_warning(self, mock_get_origin_data):
        fake_logger = fixtures.FakeLogger(level=logging.WARN)
        self.useFixture(fake_logger)

        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main/a]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main/a": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(1))

        m = 'DEPRECATED: Found a "/" in the name of the {!r} part'.format("main/a")
        self.assertTrue(
            m in fake_logger.output, "Missing slash deprecation warning in output"
        )
Exemple #20
0
    def test_multiple_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with multiple origin parts."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: ['main', 'subpart']
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                    "after": ["subpart"],
                },
                "subpart": {
                    "source": "lp:somethingelse",
                    "plugin": "copy",
                    "files": ["subfile2"],
                },
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(2))
Exemple #21
0
    def test_n_documents(self, mock_get_origin_data):
        """Test 2 wiki entries."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main2]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
                'main2': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.assertEqual(2, _get_part_list_count())
Exemple #22
0
    def test_source_with_local_source_subdir_part_origin(
            self, mock_get_origin_data):
        """Test a wiki entry with a source with a local source-subdir part."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': '.',
                    'source-subdir': 'local',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.assertEqual(1, _get_part_list_count())
        part = _get_part('main')
        self.assertNotEqual('.', part['source'])
        self.assertEqual('local', part['source-subdir'])
        self.assertEqual(6, len(part.keys()))
Exemple #23
0
    def test_remote_after_parts_unordered(self, mock_get_origin_data):
        _create_example_output(
            """
---
maintainer: Marco Trevisan <*****@*****.**>
origin: lp:snapcraft-parser-example
description: parent part that depends on child
parts: [parent]
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example part on which parent depends on
parts: [child]
"""
        )
        parts = OrderedDict()

        parent_part = OrderedDict()
        parent_part["description"] = "example part on which parent depends on"
        parent_part["maintainer"] = "Marco Trevisan <*****@*****.**>"
        parent_part["plugin"] = "dump"
        parent_part["source"] = "lp:project"
        parent_part["after"] = ["child"]
        parts["parent"] = parent_part

        child_part = OrderedDict()
        child_part["description"] = "parent part that depends on child"
        child_part["maintainer"] = "John Doe <*****@*****.**>"
        child_part["plugin"] = "dump"
        child_part["source"] = "lp:project"
        parts["child"] = child_part

        mock_get_origin_data.return_value = {"parts": parts}
        main(["--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(2))
Exemple #24
0
    def test_main_valid_with_default_index(self, mock_urlopen):
        class FakeResponse:
            def read(self):
                return b""

        mock_urlopen.return_value = FakeResponse()
        main(["--debug"])
        self.assertThat(_get_part_list_count(), Equals(0))
Exemple #25
0
    def test_parsed_output_matches_wiki_order(
            self, mock_get, mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [main2]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [app1]
""")
        parts = OrderedDict()

        parts_main = OrderedDict()
        parts_main['description'] = 'example main'
        parts_main['files'] = ['file1', 'file2']
        parts_main['maintainer'] = 'John Doe <*****@*****.**>'
        parts_main['plugin'] = 'copy'
        parts_main['source'] = 'lp:project'
        parts['main'] = parts_main

        parts_main2 = OrderedDict()
        parts_main2['description'] = 'example main2'
        parts_main2['files'] = ['file1', 'file2']
        parts_main2['maintainer'] = 'Jim Doe <*****@*****.**>'
        parts_main2['plugin'] = 'copy'
        parts_main2['source'] = 'lp:project'
        parts['main2'] = parts_main2

        parts_app1 = OrderedDict()
        parts_app1['description'] = 'example main2'
        parts_app1['files'] = ['file1', 'file2']
        parts_app1['maintainer'] = 'Jim Doe <*****@*****.**>'
        parts_app1['plugin'] = 'copy'
        parts_app1['source'] = 'lp:project'
        parts['app1'] = parts_app1

        mock_get_origin_data.return_value = {
            'parts': parts,
        }
        main(['--index', TEST_OUTPUT_PATH])
        self.assertEqual(3, _get_part_list_count())

        self.assertEqual(parts,
                         _get_part_list())
Exemple #26
0
    def test_parsed_output_matches_wiki_order(self, mock_get_origin_data):
        _create_example_output(
            """
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [main2]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [app1]
"""
        )
        parts = OrderedDict()

        parts_main = OrderedDict()
        parts_main["description"] = "example main"
        parts_main["files"] = ["file1", "file2"]
        parts_main["maintainer"] = "John Doe <*****@*****.**>"
        parts_main["plugin"] = "copy"
        parts_main["source"] = "lp:project"
        parts["main"] = parts_main

        parts_main2 = OrderedDict()
        parts_main2["description"] = "example main2"
        parts_main2["files"] = ["file1", "file2"]
        parts_main2["maintainer"] = "Jim Doe <*****@*****.**>"
        parts_main2["plugin"] = "copy"
        parts_main2["source"] = "lp:project"
        parts["main2"] = parts_main2

        parts_app1 = OrderedDict()
        parts_app1["description"] = "example main2"
        parts_app1["files"] = ["file1", "file2"]
        parts_app1["maintainer"] = "Jim Doe <*****@*****.**>"
        parts_app1["plugin"] = "copy"
        parts_app1["source"] = "lp:project"
        parts["app1"] = parts_app1

        mock_get_origin_data.return_value = {"parts": parts}
        main(["--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(3))

        self.assertThat(parts, Equals(_get_part_list()))
Exemple #27
0
    def test_parsed_output_matches_wiki_order(self, mock_get_origin_data):
        _create_example_output(
            """
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [main2]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [app1]
"""
        )
        parts = OrderedDict()

        parts_main = OrderedDict()
        parts_main["description"] = "example main"
        parts_main["files"] = ["file1", "file2"]
        parts_main["maintainer"] = "John Doe <*****@*****.**>"
        parts_main["plugin"] = "copy"
        parts_main["source"] = "lp:project"
        parts["main"] = parts_main

        parts_main2 = OrderedDict()
        parts_main2["description"] = "example main2"
        parts_main2["files"] = ["file1", "file2"]
        parts_main2["maintainer"] = "Jim Doe <*****@*****.**>"
        parts_main2["plugin"] = "copy"
        parts_main2["source"] = "lp:project"
        parts["main2"] = parts_main2

        parts_app1 = OrderedDict()
        parts_app1["description"] = "example main2"
        parts_app1["files"] = ["file1", "file2"]
        parts_app1["maintainer"] = "Jim Doe <*****@*****.**>"
        parts_app1["plugin"] = "copy"
        parts_app1["source"] = "lp:project"
        parts["app1"] = parts_app1

        mock_get_origin_data.return_value = {"parts": parts}
        main(["--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(3))

        self.assertThat(parts, Equals(_get_part_list()))
Exemple #28
0
    def test_parsed_output_matches_wiki_order(self, mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [main2]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [app1]
""")
        parts = OrderedDict()

        parts_main = OrderedDict()
        parts_main['description'] = 'example main'
        parts_main['files'] = ['file1', 'file2']
        parts_main['maintainer'] = 'John Doe <*****@*****.**>'
        parts_main['plugin'] = 'copy'
        parts_main['source'] = 'lp:project'
        parts['main'] = parts_main

        parts_main2 = OrderedDict()
        parts_main2['description'] = 'example main2'
        parts_main2['files'] = ['file1', 'file2']
        parts_main2['maintainer'] = 'Jim Doe <*****@*****.**>'
        parts_main2['plugin'] = 'copy'
        parts_main2['source'] = 'lp:project'
        parts['main2'] = parts_main2

        parts_app1 = OrderedDict()
        parts_app1['description'] = 'example main2'
        parts_app1['files'] = ['file1', 'file2']
        parts_app1['maintainer'] = 'Jim Doe <*****@*****.**>'
        parts_app1['plugin'] = 'copy'
        parts_app1['source'] = 'lp:project'
        parts['app1'] = parts_app1

        mock_get_origin_data.return_value = {
            'parts': parts,
        }
        main(['--index', TEST_OUTPUT_PATH])
        self.assertEqual(3, _get_part_list_count())

        self.assertEqual(parts, _get_part_list())
Exemple #29
0
    def test_origin_options(self, mock_get_origin_data, mock_get_base_dir):
        _create_example_output(
            """
{{{
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
origin-type: bzr
origin-branch: stable-branch
origin-commit: 123
origin-tag: source-tag
description: example
parts: [main]
}}}
"""
        )
        mock_get_base_dir.return_value = tempfile.mkdtemp()
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.mock_get.assert_has_calls(
            [mock.call("lp:snapcraft-parser-example", source_type="bzr")]
        )

        mock_source_handler = self.mock_get.return_value
        mock_source_handler.assert_has_calls(
            [
                mock.call(
                    "lp:snapcraft-parser-example",
                    source_dir=os.path.join(
                        parser._get_base_dir(),
                        _encode_origin("lp:snapcraft-parser-example"),
                    ),
                )
            ]
        )

        mock_handler = mock_source_handler.return_value
        self.assertThat(mock_handler.source_branch, Equals("stable-branch"))
        self.assertThat(mock_handler.source_commit, Equals(123))
        self.assertThat(mock_handler.source_tag, Equals("source-tag"))
Exemple #30
0
    def test_origin_options(self, mock_get_origin_data, mock_get_base_dir):
        _create_example_output(
            """
{{{
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
origin-type: bzr
origin-branch: stable-branch
origin-commit: 123
origin-tag: source-tag
description: example
parts: [main]
}}}
"""
        )
        mock_get_base_dir.return_value = tempfile.mkdtemp()
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.mock_get.assert_has_calls(
            [mock.call("lp:snapcraft-parser-example", source_type="bzr")]
        )

        mock_source_handler = self.mock_get.return_value
        mock_source_handler.assert_has_calls(
            [
                mock.call(
                    "lp:snapcraft-parser-example",
                    source_dir=os.path.join(
                        parser._get_base_dir(),
                        _encode_origin("lp:snapcraft-parser-example"),
                    ),
                )
            ]
        )

        mock_handler = mock_source_handler.return_value
        self.assertThat(mock_handler.source_branch, Equals("stable-branch"))
        self.assertThat(mock_handler.source_commit, Equals(123))
        self.assertThat(mock_handler.source_tag, Equals("source-tag"))
Exemple #31
0
    def test_filenotfound_for_non_repos(self, mock_type, mock_pull):
        mock_pull.side_effect = FileNotFoundError()
        mock_type.return_value = None
        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:not-a-real-snapcraft-parser-example
description: example main
parts: [main]
""")
        with self.assertRaises(FileNotFoundError):
            main(['--debug', '--index', TEST_OUTPUT_PATH])
Exemple #32
0
    def test_filenotfound_for_non_repos(self, mock_type, mock_pull):
        mock_pull.side_effect = FileNotFoundError()
        mock_type.return_value = None
        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:not-a-real-snapcraft-parser-example
description: example main
parts: [main]
""")
        with self.assertRaises(FileNotFoundError):
            main(['--debug', '--index', TEST_OUTPUT_PATH])
Exemple #33
0
    def test_wiki_interactions_with_fake(self, mock_get, mock_get_origin_data):

        fixture = fixture_setup.FakePartsWiki()
        self.useFixture(fixture)

        mock_get_origin_data.return_value = {
            'parts': {
                'curl': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', fixture.fake_parts_wiki_fixture.url])
        self.assertEqual(1, _get_part_list_count())
Exemple #34
0
    def test_missing_fields(self, mock_get_origin_data):
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }

        retval = main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(0))
        self.assertThat(retval, Equals(2))
Exemple #35
0
    def test_missing_packages(self):
        self.mock_check_command.side_effect = MissingCommandError("bzr")
        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:not-a-real-snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: John Doe <*****@*****.**>
origin: lp:not-a-real-snapcraft-parser-example
description: example main
parts: [main2]
""")
        retval = main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(retval, Equals(2))

        self.assertTrue(
            "Failed to run command: "
            "One or more packages are missing, please install"
            in fake_logger.output,
            "No missing package info in output",
        )
Exemple #36
0
    def test_main_valid_variable_substition(self, mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            "name": "something",
            "version": "0.1",
            "parts": {
                "main": {
                    "source": "lp:$SNAPCRAFT_PROJECT_NAME"
                    "/r$SNAPCRAFT_PROJECT_VERSION",
                    "plugin": "copy",
                    "files": ["$SNAPCRAFT_PROJECT_NAME/file1", "file2"],
                }
            },
        }
        retval = main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(1))
        part = _get_part("main")
        self.assertThat(part["source"], Equals("lp:something/r0.1"))
        self.assertIn("something/file1", part["files"])
        self.assertThat(retval, Equals(0))
Exemple #37
0
    def test_wiki_interactions_with_fake(self, mock_get_origin_data):

        fixture = fixture_setup.FakePartsWiki()
        self.useFixture(fixture)

        mock_get_origin_data.return_value = {
            "parts": {
                "curl": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", fixture.fake_parts_wiki_fixture.url])
        self.assertThat(_get_part_list_count(), Equals(1))
Exemple #38
0
    def test_main_valid_variable_substition(self, mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'name': 'something',
            'version': '0.1',
            'parts': {
                'main': {
                    'source': 'lp:$SNAPCRAFT_PROJECT_NAME'
                              '/r$SNAPCRAFT_PROJECT_VERSION',

                    'plugin': 'copy',
                    'files': ['$SNAPCRAFT_PROJECT_NAME/file1', 'file2'],
                },
            }
        }
        retval = main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(1, _get_part_list_count())
        part = _get_part('main')
        self.assertEqual(part['source'], 'lp:something/r0.1')
        self.assertIn('something/file1', part['files'])
        self.assertEqual(0, retval)
Exemple #39
0
    def test_origin_part_without_source(self, mock_get_origin_data):
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {"main": {"plugin": "copy", "files": ["file1", "file2"]}}
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(1))
        self.assertThat(len(_get_part("main").keys()), Equals(4))
Exemple #40
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())
Exemple #41
0
    def test_missing_snapcraft_yaml_without_debug(self):

        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())
Exemple #42
0
    def test_wiki_interactions_with_fake(self, mock_get_origin_data):

        fixture = fixture_setup.FakePartsWiki()
        self.useFixture(fixture)

        mock_get_origin_data.return_value = {
            'parts': {
                'curl': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', fixture.fake_parts_wiki_fixture.url])
        self.assertEqual(1, _get_part_list_count())
Exemple #43
0
 def test_invalid_yaml(self):
     _create_example_output(":")
     retval = main(["--debug", "--index", TEST_OUTPUT_PATH])
     self.assertIn(
         "Bad wiki entry, possibly malformed YAML for entry: ",
         self.fake_logger.output,
     )
     self.assertThat(retval, Equals(1))
Exemple #44
0
    def test_missing_fields(self, mock_get, mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(0, _get_part_list_count())
Exemple #45
0
    def test_origin_part_without_source(self, mock_get, mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(1, _get_part_list_count())
        self.assertEqual(4, len(_get_part('main').keys()))
Exemple #46
0
    def test_origin_options(self, mock_get_origin_data, mock_get_base_dir):
        _create_example_output("""
{{{
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
origin-type: bzr
origin-branch: stable-branch
origin-commit: 123
origin-tag: source-tag
description: example
parts: [main]
}}}
""")
        mock_get_base_dir.return_value = tempfile.mkdtemp()
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.mock_get.assert_has_calls([
            mock.call('lp:snapcraft-parser-example', source_type='bzr')
        ])

        mock_source_handler = self.mock_get.return_value
        mock_source_handler.assert_has_calls([
            mock.call(
                'lp:snapcraft-parser-example',
                source_dir=os.path.join(
                    parser._get_base_dir(),
                    _encode_origin('lp:snapcraft-parser-example')))
        ])

        mock_handler = mock_source_handler.return_value
        self.assertEqual(mock_handler.source_branch, 'stable-branch')
        self.assertEqual(mock_handler.source_commit, 123)
        self.assertEqual(mock_handler.source_tag, 'source-tag')
Exemple #47
0
    def test_main_invalid(self, mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main, part1]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                    'after': ['part1'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(0))
Exemple #48
0
    def test_single_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with a single origin part."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(1))
Exemple #49
0
    def test_single_part_origin(self, mock_get, mock_get_origin_data):
        """Test a wiki entry with a single origin part."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
project-part: main
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.assertEqual(1, _get_part_list_count())
Exemple #50
0
    def test_duplicate_entries(self, mock_get_origin_data):
        """Test duplicate parts are ignored."""

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

        _create_example_output(
            """
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main duplicate
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                }
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        part = _get_part("main")
        self.assertThat(part["description"], Equals("example main"))

        self.assertThat(_get_part_list_count(), Equals(1))

        self.assertTrue(
            "Duplicate part found in the wiki: main" in fake_logger.output,
            "Missing duplicate part info in output",
        )
Exemple #51
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')
Exemple #52
0
    def test_partial_processing_for_malformed_yaml(self, mock_get_origin_data):
        _create_example_output(
            """
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description:
  example

  Usage
    blahblahblah
parts: [main]
---
maintainer: John Doeson <*****@*****.**>
origin: lp:snapcraft-parser-example
description:
  example

  Usage:
    blahblahblah
parts: [main2]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
                "main2": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(1))
Exemple #53
0
    def test_source_with_local_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with a source with a local part."""
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
"""
        )
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {"source": ".", "plugin": "copy", "files": ["file1", "file2"]}
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        self.assertThat(_get_part_list_count(), Equals(1))
        part = _get_part("main")
        self.assertNotEqual(".", part["source"])
        self.assertThat(len(part.keys()), Equals(5))
Exemple #54
0
    def test_maintaner_is_included(self, mock_get_origin_data):
        """Test maintainer is included in parsed parts."""
        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [main2]
""")
        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
                "main2": {
                    "source": "lp:project",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                },
            }
        }
        main(["--debug", "--index", TEST_OUTPUT_PATH])

        part = _get_part("main")
        self.assertThat(part["maintainer"],
                        Equals("John Doe <*****@*****.**>"))

        part = _get_part("main2")
        self.assertThat(part["maintainer"],
                        Equals("Jim Doe <*****@*****.**>"))

        self.assertThat(_get_part_list_count(), Equals(2))
Exemple #55
0
    def test_partial_processing_for_malformed_yaml(self,
                                                   mock_get,
                                                   mock_get_origin_data):
        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description:
  example

  Usage
    blahblahblah
parts: [main]
---
maintainer: John Doeson <*****@*****.**>
origin: lp:snapcraft-parser-example
description:
  example

  Usage:
    blahblahblah
parts: [main2]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
                'main2': {
                    'source': 'lp:something',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])
        self.assertEqual(1, _get_part_list_count())
Exemple #56
0
    def test_maintaner_is_included(self, mock_get_origin_data):
        """Test maintainer is included in parsed parts."""
        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
parts: [main2]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
                'main2': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        part = _get_part('main')
        self.assertThat(part['maintainer'],
                        Equals('John Doe <*****@*****.**>'))

        part = _get_part('main2')
        self.assertThat(part['maintainer'],
                        Equals('Jim Doe <*****@*****.**>'))

        self.assertThat(_get_part_list_count(), Equals(2))
Exemple #57
0
    def test_duplicate_entries(self, mock_get, mock_get_origin_data):
        """Test duplicate parts are ignored."""

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

        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
parts: [main]
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main duplicate
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        part = _get_part('main')
        self.assertEqual('example main', part['description'])

        self.assertEqual(1, _get_part_list_count())

        self.assertTrue(
            'Duplicate part found in the wiki: main' in fake_logger.output,
            'Missing duplicate part info in output')
Exemple #58
0
    def test_description_is_included(self, mock_get, mock_get_origin_data):
        """Test description is included in parsed parts."""
        _create_example_output("""
---
maintainer: John Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main
project-part: main
---
maintainer: Jim Doe <*****@*****.**>
origin: lp:snapcraft-parser-example
description: example main2
project-part: main2
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
                'main2': {
                    'source': 'lp:project',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        part = _get_part('main')
        self.assertEqual('example main', part['description'])

        part = _get_part('main2')
        self.assertEqual('example main2', part['description'])

        self.assertEqual(2, _get_part_list_count())
Exemple #59
0
    def test_main_nested_parts_invalid(self, mock_get_origin_data):
        """Ensure that we fail if there are dependent parts that
        are not included in the wiki's 'parts' section."""

        mock_get_origin_data.return_value = {
            "parts": {
                "main": {
                    "source": "lp:something",
                    "plugin": "copy",
                    "files": ["file1", "file2"],
                    "after": ["part1"],
                },
                "part1": {
                    "source": "lp:somethingelse1",
                    "plugin": "copy",
                    "files": ["subfile1"],
                    "after": ["part2"],
                },
                "part2": {
                    "source": "lp:somethingelse2",
                    "plugin": "copy",
                    "files": ["subfile2"],
                },
            }
        }
        _create_example_output(
            """
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main, part1]
"""
        )
        main(["--debug", "--index", TEST_OUTPUT_PATH])
        self.assertThat(_get_part_list_count(), Equals(0))
Exemple #60
0
    def test_source_with_local_part_origin(self, mock_get_origin_data):
        """Test a wiki entry with a source with a local part."""
        _create_example_output("""
---
maintainer: John Doe <[email protected]
origin: lp:snapcraft-parser-example
description: example
parts: [main]
""")
        mock_get_origin_data.return_value = {
            'parts': {
                'main': {
                    'source': '.',
                    'plugin': 'copy',
                    'files': ['file1', 'file2'],
                },
            }
        }
        main(['--debug', '--index', TEST_OUTPUT_PATH])

        self.assertEqual(1, _get_part_list_count())
        part = _get_part('main')
        self.assertNotEqual('.', part['source'])
        self.assertEqual(5, len(part.keys()))