def test_multiple_lines_separated_in_project(self):
     global_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     project_content = textwrap.dedent("""\
         foo<1.8;python_version=='2.7'
         # mumbo gumbo
         foo>0.9;python_version!='2.7'
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(requirement.Requirements([
         requirement.Requirement(
             'foo', '', '<2', "python_version=='2.7'", ''),
         requirement.Requirement(
             'foo', '', '>1', "python_version!='2.7'", ''),
         requirement.Requirement(
             '', '', '', '', "# mumbo gumbo")]),
         reqs)
     self.assertEqual(project.StdOut(
         "    foo<1.8;python_version=='2.7'  ->   "
         "foo<2;python_version=='2.7'\n"), actions[2])
     self.assertEqual(project.StdOut(
         "    foo>0.9;python_version!='2.7'  ->   "
         "foo>1;python_version!='2.7'\n"), actions[3])
     self.assertThat(actions, matchers.HasLength(4))
 def test_multiple_lines_separated_in_project(self):
     global_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     project_content = textwrap.dedent("""\
         foo<1.8;python_version=='2.7'
         # mumbo gumbo
         foo>0.9;python_version!='2.7'
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(global_reqs,
                                                    project_reqs, 'f',
                                                    False, False, False)
     self.assertEqual(
         requirement.Requirements([
             requirement.Requirement('foo', '', '<2',
                                     "python_version=='2.7'", ''),
             requirement.Requirement('foo', '', '>1',
                                     "python_version!='2.7'", ''),
             requirement.Requirement('', '', '', '', "# mumbo gumbo")
         ]), reqs)
     self.assertEqual(
         project.StdOut("    foo<1.8;python_version=='2.7'  ->   "
                        "foo<2;python_version=='2.7'\n"), actions[2])
     self.assertEqual(
         project.StdOut("    foo>0.9;python_version!='2.7'  ->   "
                        "foo>1;python_version!='2.7'\n"), actions[3])
     self.assertThat(actions, matchers.HasLength(4))
Exemple #3
0
def _copy_requires(suffix,
                   softupdate,
                   hacking,
                   proj,
                   global_reqs,
                   non_std_reqs,
                   blacklist={}):
    """Copy requirements files."""
    actions = []
    for source, content in sorted(proj['requirements'].items()):
        dest_path = os.path.join(proj['root'], source)
        # this is specifically for global-requirements gate jobs so we don't
        # modify the git tree
        if suffix:
            dest_path = "%s.%s" % (dest_path, suffix)
            dest_name = "%s.%s" % (source, suffix)
        else:
            dest_name = source
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing %s" % dest_path))
        _actions, reqs = _sync_requirements_file(global_reqs, dest_sequence,
                                                 dest_path, softupdate,
                                                 hacking, non_std_reqs,
                                                 blacklist)
        actions.extend(_actions)
        actions.append(project.File(dest_name, requirement.to_content(reqs)))
    extras = project.extras(proj)
    output_extras = {}
    for extra, content in sorted(extras.items()):
        dest_name = 'extra-%s' % extra
        dest_path = "%s[%s]" % (proj['root'], extra)
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing extra [%s]" % extra))
        _actions, reqs = _sync_requirements_file(global_reqs, dest_sequence,
                                                 dest_path, softupdate,
                                                 hacking, non_std_reqs,
                                                 blacklist)
        actions.extend(_actions)
        output_extras[extra] = reqs
    dest_path = 'setup.cfg'
    if suffix:
        dest_path = "%s.%s" % (dest_path, suffix)
    actions.append(
        project.File(dest_path,
                     project.merge_setup_cfg(proj['setup.cfg'],
                                             output_extras)))
    return actions
Exemple #4
0
 def test_not_urls(self):
     try:
         list(requirement.to_reqs('file:///foo#egg=foo'))
     except (pkg_resources.RequirementParseError,
             pkg_resources_reqs.InvalidRequirement):
         pass
     else:
         self.fail('No exception triggered')
Exemple #5
0
def _copy_requires(
        suffix, softupdate, hacking, proj, global_reqs, non_std_reqs,
        blacklist={}):
    """Copy requirements files."""
    actions = []
    for source, content in sorted(proj['requirements'].items()):
        dest_path = os.path.join(proj['root'], source)
        # this is specifically for global-requirements gate jobs so we don't
        # modify the git tree
        if suffix:
            dest_path = "%s.%s" % (dest_path, suffix)
            dest_name = "%s.%s" % (source, suffix)
        else:
            dest_name = source
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing %s" % dest_path))
        _actions, reqs = _sync_requirements_file(
            global_reqs, dest_sequence, dest_path, softupdate, hacking,
            non_std_reqs, blacklist)
        actions.extend(_actions)
        actions.append(project.File(dest_name, requirement.to_content(reqs)))
    extras = project.extras(proj)
    output_extras = {}
    for extra, content in sorted(extras.items()):
        dest_name = 'extra-%s' % extra
        dest_path = "%s[%s]" % (proj['root'], extra)
        dest_sequence = list(requirement.to_reqs(content))
        actions.append(project.Verbose("Syncing extra [%s]" % extra))
        _actions, reqs = _sync_requirements_file(
            global_reqs, dest_sequence, dest_path, softupdate, hacking,
            non_std_reqs, blacklist)
        actions.extend(_actions)
        output_extras[extra] = reqs
    dest_path = 'setup.cfg'
    if suffix:
        dest_path = "%s.%s" % (dest_path, suffix)
    actions.append(project.File(
        dest_path, project.merge_setup_cfg(proj['setup.cfg'], output_extras)))
    return actions
Exemple #6
0
 def test_unparseable_line(self):
     global_content = textwrap.dedent("""\
         foo
         """)
     project_content = textwrap.dedent("""\
         foo
         -e https://git.openstack.org/openstack/neutron.git#egg=neutron
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     n = '-e https://git.openstack.org/openstack/neutron.git#egg=neutron'
     self.assertEqual(requirement.Requirements([
         requirement.Requirement('foo', '', '', '', ''),
         requirement.Requirement('', '', '', '', n)]),
         reqs)
 def test_unparseable_line(self):
     global_content = textwrap.dedent("""\
         foo
         """)
     project_content = textwrap.dedent("""\
         foo
         -e https://git.openstack.org/openstack/neutron.git#egg=neutron
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     n = '-e https://git.openstack.org/openstack/neutron.git#egg=neutron'
     self.assertEqual(requirement.Requirements([
         requirement.Requirement('foo', '', '', '', ''),
         requirement.Requirement('', '', '', '', n)]),
         reqs)
Exemple #8
0
 def test_extras_kept(self):
     global_content = textwrap.dedent("""\
         oslo.db>1.4.1
         """)
     project_content = textwrap.dedent("""\
         oslo.db[fixture,mysql]>1.3
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(requirement.Requirements([
         requirement.Requirement(
             'oslo.db', '', '>1.4.1', '', '', ['fixture', 'mysql'])]),
         reqs)
     self.assertThat(actions, matchers.HasLength(3))
     self.assertEqual(project.StdOut(
         "    oslo.db[fixture,mysql]>1.3     ->   "
         "oslo.db[fixture,mysql]>1.4.1\n"), actions[2])
 def test_extras_kept(self):
     global_content = textwrap.dedent("""\
         oslo.db>1.4.1
         """)
     project_content = textwrap.dedent("""\
         oslo.db[fixture,mysql]>1.3
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(requirement.Requirements([
         requirement.Requirement(
             'oslo.db', '', '>1.4.1', '', '', ['fixture', 'mysql'])]),
         reqs)
     self.assertThat(actions, matchers.HasLength(3))
     self.assertEqual(project.StdOut(
         "    oslo.db[fixture,mysql]>1.3     ->   "
         "oslo.db[fixture,mysql]>1.4.1\n"), actions[2])
Exemple #10
0
 def test_multiple_lines_nochange(self):
     global_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     project_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(requirement.Requirements([
         requirement.Requirement(
             'foo', '', '<2', "python_version=='2.7'", ''),
         requirement.Requirement(
             'foo', '', '>1', "python_version!='2.7'", '')]),
         reqs)
     self.assertThat(actions, matchers.HasLength(0))
Exemple #11
0
 def test_multiple_lines_nochange(self):
     global_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     project_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(requirement.Requirements([
         requirement.Requirement(
             'foo', '', '<2', "python_version=='2.7'", ''),
         requirement.Requirement(
             'foo', '', '>1', "python_version!='2.7'", '')]),
         reqs)
     self.assertThat(actions, matchers.HasLength(0))
Exemple #12
0
 def test_single_global_multiple_in_project(self):
     global_content = textwrap.dedent("""\
         foo>1
         """)
     project_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(requirement.Requirements([
         requirement.Requirement('foo', '', '>1', "", '')]),
         reqs)
     self.assertEqual(project.StdOut(
         "    foo<2;python_version=='2.7'    ->   foo>1\n"), actions[2])
     self.assertEqual(project.StdOut(
         "    foo>1;python_version!='2.7'    ->   \n"), actions[3])
     self.assertThat(actions, matchers.HasLength(4))
Exemple #13
0
 def test_single_global_multiple_in_project(self):
     global_content = textwrap.dedent("""\
         foo>1
         """)
     project_content = textwrap.dedent("""\
         foo<2;python_version=='2.7'
         foo>1;python_version!='2.7'
         """)
     global_reqs = requirement.parse(global_content)
     project_reqs = list(requirement.to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(requirement.Requirements([
         requirement.Requirement('foo', '', '>1', "", '')]),
         reqs)
     self.assertEqual(project.StdOut(
         "    foo<2;python_version=='2.7'    ->   foo>1\n"), actions[2])
     self.assertEqual(project.StdOut(
         "    foo>1;python_version!='2.7'    ->   \n"), actions[3])
     self.assertThat(actions, matchers.HasLength(4))
Exemple #14
0
 def test_urls(self):
     line = 'file:///foo#egg=foo'
     reqs = list(requirement.to_reqs(line, permit_urls=True))
     req = requirement.Requirement('foo', 'file:///foo', '', '', '')
     self.assertEqual(reqs, [(req, line)])
 def test_not_urls(self):
     with testtools.ExpectedException(pkg_resources.RequirementParseError):
         list(requirement.to_reqs("file:///foo#egg=foo"))
 def test_urls(self):
     line = "file:///foo#egg=foo"
     reqs = list(requirement.to_reqs(line, permit_urls=True))
     req = requirement.Requirement("foo", "file:///foo", "", "", "")
     self.assertEqual(reqs, [(req, line)])
Exemple #17
0
 def test_not_urls(self):
     with testtools.ExpectedException(pkg_resources.RequirementParseError):
         list(requirement.to_reqs('file:///foo#egg=foo'))
 def test_urls(self):
     line = 'file:///foo#egg=foo'
     reqs = list(requirement.to_reqs(line, permit_urls=True))
     req = requirement.Requirement('foo', 'file:///foo', '', '', '')
     self.assertEqual(reqs, [(req, line)])
 def test_not_urls(self):
     with testtools.ExpectedException(InvalidRequirement):
         list(requirement.to_reqs('file:///foo#egg=foo'))
Exemple #20
0
 def test_not_urls(self):
     with testtools.ExpectedException(InvalidRequirement):
         list(requirement.to_reqs('file:///foo#egg=foo'))