예제 #1
0
    def test_owner_pr_submitter_is_not_maintainer_of_all_updated_files(self):
        """
        PR updates 2 files below module_utils, submitter is a maintainer from only one: ensure owner_pr isn't set
        """
        BOTMETA = u"""
        ---
        macros:
            modules: lib/ansible/modules
            module_utils: lib/ansible/module_utils
        files:
            $module_utils/foo/bar.py:
                maintainers: ElsA Oliver
            $module_utils/baz/bar.py:
                maintainers: TiTi ZaZa
        """

        module_indexer = create_indexer(textwrap.dedent(BOTMETA), {})

        self.assertEqual(len(module_indexer.modules), 1)  # ensure only fake data are loaded
        self.assertEqual(sorted(module_indexer.botmeta[u'files'][u'lib/ansible/module_utils/foo/bar.py'][u'maintainers']), [u'ElsA', u'Oliver'])
        self.assertEqual(sorted(module_indexer.botmeta[u'files'][u'lib/ansible/module_utils/baz/bar.py'][u'maintainers']), [u'TiTi', u'ZaZa'])

        CM = ComponentMatcherMock()
        CM.expected_results = [
            {
                u'repo_filename': u'lib/ansible/module_utils/foo/bar.py',
                u'labels': [],
                u'support': None,
                u'maintainers': [u'ElsA', u'Oliver'],
                u'notify': [u'ElsA', u'Oliver'],
                u'ignore': [],
            },
            {
                u'repo_filename': u'lib/ansible/modules/baz/bar.py',
                u'labels': [],
                u'support': None,
                u'maintainers': [u'TiTi', u'ZaZa'],
                u'notify': [u'TiTi', u'ZaZa'],
                u'ignore': [],
            }
        ]

        issue = IssueMock(u'/dev/null')
        issue.user.login = u'ElsA'
        issue.html_url = u'https://github.com/ansible/ansible/pull/123'
        iw = IssueWrapper(cachedir="", issue=issue)
        iw.pr_files = [
            MockFile(u'lib/ansible/module_utils/foo/bar.py'),
            MockFile(u'lib/ansible/module_utils/baz/bar.py')
        ]
        iw.file_indexer = FileIndexerMock()
        iw.repo = MockRepo(repo_path='ansible/ansible')

        meta = self.meta.copy()
        iw._commits = []
        meta.update(get_component_match_facts(iw, CM, []))
        facts = get_shipit_facts(iw, meta, module_indexer, core_team=[u'bcoca', u'mscherer'], botnames=[u'ansibot'])

        self.assertEqual(iw.submitter, u'ElsA')
        self.assertFalse(facts[u'owner_pr'])
예제 #2
0
    def test_owner_pr_submitter_is_not_maintainer_of_all_updated_files(self):
        """
        PR updates 2 files below module_utils, submitter is a maintainer from only one: ensure owner_pr isn't set
        """
        BOTMETA = u"""
        ---
        macros:
            modules: lib/ansible/modules
            module_utils: lib/ansible/module_utils
        files:
            $module_utils/foo/bar.py:
                maintainers: ElsA Oliver
            $module_utils/baz/bar.py:
                maintainers: TiTi ZaZa
        """

        module_indexer = create_indexer(textwrap.dedent(BOTMETA), {})

        self.assertEqual(len(module_indexer.modules),
                         1)  # ensure only fake data are loaded
        self.assertEqual(
            sorted(module_indexer.botmeta[u'files']
                   [u'lib/ansible/module_utils/foo/bar.py'][u'maintainers']),
            [u'ElsA', u'Oliver'])
        self.assertEqual(
            sorted(module_indexer.botmeta[u'files']
                   [u'lib/ansible/module_utils/baz/bar.py'][u'maintainers']),
            [u'TiTi', u'ZaZa'])

        CM = ComponentMatcherMock()
        CM.expected_results = [{
            u'repo_filename': u'lib/ansible/module_utils/foo/bar.py',
            u'labels': [],
            u'support': None,
            u'maintainers': [u'ElsA', u'Oliver'],
            u'notify': [u'ElsA', u'Oliver'],
            u'ignore': [],
        }, {
            u'repo_filename': u'lib/ansible/modules/baz/bar.py',
            u'labels': [],
            u'support': None,
            u'maintainers': [u'TiTi', u'ZaZa'],
            u'notify': [u'TiTi', u'ZaZa'],
            u'ignore': [],
        }]

        issue = IssueMock(u'/dev/null')
        issue.user.login = u'ElsA'
        issue.html_url = u'https://github.com/ansible/ansible/pull/123'
        cachedir = tempfile.mkdtemp()
        iw = IssueWrapper(cachedir=cachedir, issue=issue)
        iw.pr_files = [
            MockFile(u'lib/ansible/module_utils/foo/bar.py'),
            MockFile(u'lib/ansible/module_utils/baz/bar.py')
        ]
        iw.file_indexer = FileIndexerMock()
        iw.repo = MockRepo(repo_path='ansible/ansible')

        meta = self.meta.copy()
        iw._commits = []
        meta.update(get_component_match_facts(iw, CM, []))
        facts = get_shipit_facts(iw,
                                 meta,
                                 module_indexer,
                                 core_team=[u'bcoca', u'mscherer'],
                                 botnames=[u'ansibot'])
        shutil.rmtree(cachedir)

        self.assertEqual(iw.submitter, u'ElsA')
        self.assertFalse(facts[u'owner_pr'])