示例#1
0
    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 = update._parse_reqs(global_content)
        project_reqs = list(update._content_to_reqs(project_content))
        actions = update._sync_requirements_file(
            global_reqs, project_reqs, 'f', False, False, 'f', False)
        self.assertEqual(update.File('f', textwrap.dedent("""\
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
foo<2;python_version=='2.7'
foo>1;python_version!='2.7'
# mumbo gumbo
""")), actions[1])
        self.assertEqual(update.StdOut(
            "    foo<1.8;python_version=='2.7'  ->   "
            "foo<2;python_version=='2.7'\n"), actions[4])
        self.assertEqual(update.StdOut(
            "    foo>0.9;python_version!='2.7'  ->   "
            "foo>1;python_version!='2.7'\n"), actions[5])
        self.assertThat(actions, matchers.HasLength(6))
示例#2
0
 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 = update._parse_reqs(global_content)
     project_reqs = list(update._content_to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(update.Requirements([
         update.Requirement('foo', '<2', "python_version=='2.7'", ''),
         update.Requirement('foo', '>1', "python_version!='2.7'", ''),
         update.Requirement('', '', '', "# mumbo gumbo")]),
         reqs)
     self.assertEqual(update.StdOut(
         "    foo<1.8;python_version=='2.7'  ->   "
         "foo<2;python_version=='2.7'\n"), actions[2])
     self.assertEqual(update.StdOut(
         "    foo>0.9;python_version!='2.7'  ->   "
         "foo>1;python_version!='2.7'\n"), actions[3])
     self.assertThat(actions, matchers.HasLength(4))
示例#3
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 = update._parse_reqs(global_content)
     project_reqs = list(update._content_to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(update.Requirements([
         update.Requirement('foo', '<2', "python_version=='2.7'", ''),
         update.Requirement('foo', '>1', "python_version!='2.7'", '')]),
         reqs)
     self.assertThat(actions, matchers.HasLength(0))
示例#4
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 = update._parse_reqs(global_content)
     project_reqs = list(update._content_to_reqs(project_content))
     actions, reqs = update._sync_requirements_file(
         global_reqs, project_reqs, 'f', False, False, False)
     self.assertEqual(update.Requirements([
         update.Requirement('foo', '>1', "", '')]),
         reqs)
     self.assertEqual(update.StdOut(
         "    foo<2;python_version=='2.7'    ->   foo>1\n"), actions[2])
     self.assertEqual(update.StdOut(
         "    foo>1;python_version!='2.7'    ->   \n"), actions[3])
     self.assertThat(actions, matchers.HasLength(4))