def test_project_missing_from_uc(self):
        self.useFixture(common.project_fixture)
        orig_mocked_read_req = check_exists.read_requirements_file
        read_req_path = ('openstack_requirements.cmds.check_exists.'
                         'read_requirements_file')

        def remove_req_read_reqs_file(filename):
            if filename == 'upper-constraints.txt':
                upper_cons = common.upper_constraints.copy()
                upper_cons.pop('six')
                return upper_cons

            return orig_mocked_read_req(filename)

        expected_out = ('six from requirements.txt not found in'
                        ' upper-constraints')

        # Start capturing some output
        mock_stdout = io.StringIO()
        with mock.patch('openstack_requirements.project.read',
                        return_value=common.project_project), \
                mock.patch('sys.stdout', mock_stdout), \
                mock.patch(read_req_path, remove_req_read_reqs_file):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        self.assertIn(expected_out, mock_stdout.getvalue())
Exemplo n.º 2
0
    def test_project_missing_from_uc(self):
        self.useFixture(common.project_fixture)
        orig_mocked_read_req = check_exists.read_requirements_file
        read_req_path = ('openstack_requirements.cmds.check_exists.'
                         'read_requirements_file')

        def remove_req_read_reqs_file(filename):
            if filename == 'upper-constraints.txt':
                upper_cons = common.upper_constraints.copy()
                upper_cons.pop('six')
                return upper_cons

            return orig_mocked_read_req(filename)

        expected_out = ('six from requirements.txt not found in'
                        ' upper-constraints')

        # Start capturing some output
        mock_stdout = io.StringIO()
        with mock.patch('openstack_requirements.project.read',
                        return_value=common.project_project), \
                mock.patch('sys.stdout', mock_stdout), \
                mock.patch(read_req_path, remove_req_read_reqs_file):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        self.assertIn(expected_out, mock_stdout.getvalue())
Exemplo n.º 3
0
    def test_project_req_bigger_then_uc(self):
        self.useFixture(common.project_fixture)

        # lets change the six requirement not include the u-c version
        proj_read = project.read(common.project_fixture.root)
        proj_read['requirements']['requirements.txt'] = \
            proj_read['requirements']['requirements.txt'][:-1] + '>1.10.0\n'
        expected_out = ('six must be <= 1.10.0 from upper-constraints and '
                        'include the upper-constraints version')

        # Start capturing some output
        mock_stdout = io.StringIO()
        with mock.patch('openstack_requirements.project.read',
                        return_value=proj_read), \
                mock.patch('sys.stdout', mock_stdout):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        self.assertIn(expected_out, mock_stdout.getvalue())
    def test_project_req_bigger_then_uc(self):
        self.useFixture(common.project_fixture)

        # lets change the six requirement not include the u-c version
        proj_read = project.read(common.project_fixture.root)
        proj_read['requirements']['requirements.txt'] = \
            proj_read['requirements']['requirements.txt'][:-1] + '>1.10.0\n'
        expected_out = ('six must be <= 1.10.0 from upper-constraints and '
                        'include the upper-constraints version')

        # Start capturing some output
        mock_stdout = io.StringIO()
        with mock.patch('openstack_requirements.project.read',
                        return_value=proj_read), \
                mock.patch('sys.stdout', mock_stdout):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        self.assertIn(expected_out, mock_stdout.getvalue())
Exemplo n.º 5
0
    def test_project_multiple_missing_from_uc_and_gr(self):
        self.useFixture(common.project_fixture)
        orig_mocked_read_req = check_exists.read_requirements_file
        read_req_path = ('openstack_requirements.cmds.check_exists.'
                         'read_requirements_file')

        def remove_req_read_reqs_file(filename):
            if filename == 'upper-constraints.txt':
                upper_cons = common.upper_constraints.copy()
                upper_cons.pop('lxml')
                return upper_cons

            return orig_mocked_read_req(filename)

        new_reqs = '>1.10.0\nsomerandommodule\n'

        # lets change the six requirement not include the u-c version
        proj_read = project.read(common.project_fixture.root)
        proj_read['requirements']['requirements.txt'] = \
            proj_read['requirements']['requirements.txt'][:-1] + new_reqs
        proj_read['requirements']['test-requirements.txt'] = \
            proj_read['requirements']['test-requirements.txt'] + \
            'anotherrandommodule\n'

        expected_outs = [
            'lxml from requirements.txt not found in upper-constraints',
            'somerandommodule from requirements.txt not found in '
            'global-requirements',
            'anotherrandommodule from test-requirements.txt not found in '
            'global-requirements',
            'six must be <= 1.10.0 from upper-constraints and include the '
            'upper-constraints version'
        ]

        # Start capturing some output
        mock_stdout = io.StringIO()
        with mock.patch('openstack_requirements.project.read',
                        return_value=proj_read), \
                mock.patch('sys.stdout', mock_stdout), \
                mock.patch(read_req_path, remove_req_read_reqs_file):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        for expected in expected_outs:
            self.assertIn(expected, mock_stdout.getvalue())
    def test_project_multiple_missing_from_uc_and_gr(self):
        self.useFixture(common.project_fixture)
        orig_mocked_read_req = check_exists.read_requirements_file
        read_req_path = ('openstack_requirements.cmds.check_exists.'
                         'read_requirements_file')

        def remove_req_read_reqs_file(filename):
            if filename == 'upper-constraints.txt':
                upper_cons = common.upper_constraints.copy()
                upper_cons.pop('lxml')
                return upper_cons

            return orig_mocked_read_req(filename)

        new_reqs = '>1.10.0\nsomerandommodule\n'

        # lets change the six requirement not include the u-c version
        proj_read = project.read(common.project_fixture.root)
        proj_read['requirements']['requirements.txt'] = \
            proj_read['requirements']['requirements.txt'][:-1] + new_reqs
        proj_read['requirements']['test-requirements.txt'] = \
            proj_read['requirements']['test-requirements.txt'] + \
            'anotherrandommodule\n'

        expected_outs = [
            'lxml from requirements.txt not found in upper-constraints',
            'somerandommodule from requirements.txt not found in '
            'global-requirements',
            'anotherrandommodule from test-requirements.txt not found in '
            'global-requirements',
            'six must be <= 1.10.0 from upper-constraints and include the '
            'upper-constraints version']

        # Start capturing some output
        mock_stdout = io.StringIO()
        with mock.patch('openstack_requirements.project.read',
                        return_value=proj_read), \
                mock.patch('sys.stdout', mock_stdout), \
                mock.patch(read_req_path, remove_req_read_reqs_file):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        for expected in expected_outs:
            self.assertIn(expected, mock_stdout.getvalue())
Exemplo n.º 7
0
    def test_project_missing_from_gr(self):
        self.useFixture(common.project_fixture)

        # Add some random package that wont exist in G-R
        with open(common.project_fixture.req_file, 'a') as req_file:
            req_file.write(u'SomeRandomModule #Some random module\n')
            req_file.flush()

        expected_out = ('somerandommodule from requirements.txt not found in'
                        ' global-requirements')

        # Start capturing some output
        mock_stdout = io.StringIO()
        proj_read = project.read(common.project_fixture.root)
        with mock.patch('openstack_requirements.project.read',
                        return_value=proj_read), \
                mock.patch('sys.stdout', mock_stdout):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        self.assertIn(expected_out, mock_stdout.getvalue())
    def test_project_missing_from_gr(self):
        self.useFixture(common.project_fixture)

        # Add some random package that wont exist in G-R
        with open(common.project_fixture.req_file, 'a') as req_file:
            req_file.write(u'SomeRandomModule #Some random module\n')
            req_file.flush()

        expected_out = ('somerandommodule from requirements.txt not found in'
                        ' global-requirements')

        # Start capturing some output
        mock_stdout = io.StringIO()
        proj_read = project.read(common.project_fixture.root)
        with mock.patch('openstack_requirements.project.read',
                        return_value=proj_read), \
                mock.patch('sys.stdout', mock_stdout):
            ret = check_exists.main([common.project_fixture.root])
        self.assertEqual(ret, 1)
        self.assertIn(expected_out, mock_stdout.getvalue())
Exemplo n.º 9
0
 def test_good_project(self, mock_project_read):
     ret = check_exists.main([common.project_fixture.root])
     self.assertEqual(ret, 0)
 def test_good_project(self, mock_project_read):
     ret = check_exists.main([common.project_fixture.root])
     self.assertEqual(ret, 0)