示例#1
0
    def test_review_facts_are_defined_module_utils(self):
        BOTMETA = u"""
        ---
        macros:
            modules: lib/ansible/modules
            module_utils: lib/ansible/module_utils
        files:
            $module_utils:
              support: community
            $modules/foo/bar.py:
                maintainers: ElsA ZaZa
            $module_utils/baz/bar.py:
                maintainers: TiTi mscherer
        """

        modules = {u'lib/ansible/modules/foo/bar.py': None}
        module_indexer = create_indexer(textwrap.dedent(BOTMETA), modules)

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

        datafile = u'tests/fixtures/shipit/2_issue.yml'
        statusfile = u'tests/fixtures/shipit/2_prstatus.json'
        with get_issue(datafile, statusfile) as iw:
            iw.pr_files = [MockFile(u'lib/ansible/module_utils/foo/bar.py')]
            # need to give the wrapper a list of known files to compare against
            iw.file_indexer = FileIndexerMock()
            iw.file_indexer.files.append(u'lib/ansible/modules/foo/bar.py')

            # predefine what the matcher is going to return
            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': [],
                }
            ]

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

        self.assertTrue(facts[u'community_review'])
        self.assertFalse(facts[u'core_review'])
        self.assertFalse(facts[u'committer_review'])
示例#2
0
    def test_review_facts_are_defined_module_utils(self):
        botmeta_files = {
            'lib/ansible/module_utils': {
                'support': 'community'
            },
            'lib/ansible/modules/foo/bar.py': {
                'maintainers': ['ElsA', 'ZaZa']
            },
            'lib/ansible/module_utils/baz/bar.py': {
                'maintainers': ['TiTi', 'mscherer']
            },
        }
        datafile = 'tests/fixtures/shipit/2_issue.yml'
        statusfile = 'tests/fixtures/shipit/2_prstatus.json'
        with get_issue(datafile, statusfile) as iw:
            iw.pr_files = [MockFile('lib/ansible/module_utils/foo/bar.py')]
            # need to give the wrapper a list of known files to compare against
            iw.gitrepo = GitRepoWrapperMock()
            iw.gitrepo.files.append('lib/ansible/modules/foo/bar.py')

            # predefine what the matcher is going to return
            CM = ComponentMatcherMock()
            CM.expected_results = [{
                'repo_filename': 'lib/ansible/module_utils/foo/bar.py',
                'labels': [],
                'support': None,
                'maintainers': ['ElsA', 'Oliver'],
                'notify': ['ElsA', 'Oliver'],
                'ignore': [],
            }]

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

        self.assertTrue(facts['community_review'])
        self.assertFalse(facts['core_review'])
        self.assertFalse(facts['committer_review'])