def test_extras_no_change(self):
        global_content = textwrap.dedent(u"""\
            foo<2;python_version=='2.7' # BSD
            foo>1;python_version!='2.7'
            freddy
            """)
        setup_cfg = textwrap.dedent(u"""\
            [metadata]
            name = openstack.requirements

            [extras]
            test =
              foo<2:python_version=='2.7' # BSD
              foo>1:python_version!='2.7'
            opt =
              freddy
            """)
        proj = {}
        proj['root'] = '/dev/null'
        proj['requirements'] = {}
        proj['setup.cfg'] = setup_cfg
        global_reqs = requirement.parse(global_content)
        actions = update._copy_requires(u'', False, False, proj, global_reqs,
                                        False)
        self.assertEqual([
            project.Verbose('Syncing extra [opt]'),
            project.Verbose('Syncing extra [test]'),
            project.File('setup.cfg', setup_cfg)
        ], actions)
Beispiel #2
0
 def test_non_verbose(self):
     stdout = io.StringIO()
     root = self.useFixture(fixtures.TempDir()).path
     proj = {'root': root}
     actions = [project.Verbose(u'fred')]
     project.write(proj, actions, stdout, False)
     self.expectThat(stdout.getvalue(), matchers.Equals(''))
Beispiel #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
Beispiel #4
0
def _check_setup_py(proj):
    actions = []
    # If it doesn't have a setup.py, then we don't want to update it
    if 'setup.py' not in proj:
        return actions
    # If it doesn't use pbr, we don't want to update it.
    elif 'pbr' not in proj['setup.py']:
        return actions
    # We don't update pbr's setup.py because it can't use itself.
    if 'setup.cfg' in proj and 'name = pbr' in proj['setup.cfg']:
        return actions
    actions.append(project.Verbose("Syncing setup.py"))
    actions.append(project.File('setup.py', _setup_py_text))
    return actions
Beispiel #5
0
 def test_smoke(self):
     stdout = io.StringIO()
     root = self.useFixture(fixtures.TempDir()).path
     proj = {'root': root}
     actions = [
         project.File('foo', '123\n'),
         project.File('bar', '456\n'),
         project.Verbose(u'fred')]
     project.write(proj, actions, stdout, True)
     foo = open(root + '/foo', 'rt').read()
     self.expectThat(foo, matchers.Equals('123\n'))
     bar = open(root + '/bar', 'rt').read()
     self.expectThat(bar, matchers.Equals('456\n'))
     self.expectThat(stdout.getvalue(), matchers.Equals('fred\n'))