Beispiel #1
0
 def test_parse_fns3(self):
   self.cancel_calls = 0
   def is_cancelled():
     self.cancel_calls += 1
     return None
   dump_path = os.path.join(os.path.dirname(sys.argv[0]),
       "trac/versioncontrol/tests/svnrepos.dump")
   stream = open(dump_path)
   dsp = DumpStreamParser()
   ptr, baton = repos.make_parse_fns3(dsp)
   repos.parse_dumpstream3(stream, ptr, baton, False, is_cancelled)
   stream.close()
   self.assertEqual(self.cancel_calls, 76)
   expected_list = [
       ("magic-header", 2),
       ('uuid', '92ea810a-adf3-0310-b540-bef912dcf5ba'),
       ('new-revision', 0),
       ('set-revision-prop', 0, 'svn:date', '2005-04-01T09:57:41.312767Z'),
       ('close-revision', 0),
       ('new-revision', 1),
       ('set-revision-prop', 1, 'svn:log', 'Initial directory layout.'),
       ('set-revision-prop', 1, 'svn:author', 'john'),
       ('set-revision-prop', 1, 'svn:date', '2005-04-01T10:00:52.353248Z'),
       ('new-node', 1, 'branches'),
       ('remove-node-props', 1, 'branches'),
       ('close-node', 1, 'branches'),
       ('new-node', 1, 'tags'),
       ('remove-node-props', 1, 'tags'),
       ('close-node', 1, 'tags'),
       ('new-node', 1, 'trunk'),
       ('remove-node-props', 1, 'trunk'),
       ('close-node', 1, 'trunk'),
       ('close-revision', 1),
       ('new-revision', 2),
       ('set-revision-prop', 2, 'svn:log', 'Added README.'),
       ('set-revision-prop', 2, 'svn:author', 'john'),
       ('set-revision-prop', 2, 'svn:date', '2005-04-01T13:12:18.216267Z'),
       ('new-node', 2, 'trunk/README.txt'),
       ('remove-node-props', 2, 'trunk/README.txt'),
       ('set-fulltext', 2, 'trunk/README.txt'),
       ('close-node', 2, 'trunk/README.txt'),
       ('close-revision', 2), ('new-revision', 3),
       ('set-revision-prop', 3, 'svn:log', 'Fixed README.\n'),
       ('set-revision-prop', 3, 'svn:author', 'kate'),
       ('set-revision-prop', 3, 'svn:date', '2005-04-01T13:24:58.234643Z'),
       ('new-node', 3, 'trunk/README.txt'),
       ('remove-node-props', 3, 'trunk/README.txt'),
       ('set-node-prop', 3, 'trunk/README.txt', 'svn:mime-type', 'text/plain'),
       ('set-node-prop', 3, 'trunk/README.txt', 'svn:eol-style', 'native'),
       ('set-fulltext', 3, 'trunk/README.txt'),
       ('close-node', 3, 'trunk/README.txt'), ('close-revision', 3),
       ]
   # Compare only the first X nodes described in the expected list - otherwise
   # the comparison list gets too long.
   self.assertEqual(dsp.ops[:len(expected_list)], expected_list)
Beispiel #2
0
 def test_parse_fns3_invalid_set_fulltext(self):
   class DumpStreamParserSubclass(DumpStreamParser):
     def set_fulltext(self, node_baton):
       DumpStreamParser.set_fulltext(self, node_baton)
       return 42
   stream = open(os.path.join(os.path.dirname(sys.argv[0]),
                              "trac/versioncontrol/tests/svnrepos.dump"))
   try:
     dsp = DumpStreamParserSubclass()
     ptr, baton = repos.make_parse_fns3(dsp)
     self.assertRaises(TypeError, repos.parse_dumpstream3,
                       stream, ptr, baton, False, None)
   finally:
     stream.close()
Beispiel #3
0
    def test_parse_fns3_invalid_set_fulltext(self):
        class DumpStreamParserSubclass(DumpStreamParser):
            def set_fulltext(self, node_baton):
                DumpStreamParser.set_fulltext(self, node_baton)
                return 42

        stream = open(
            os.path.join(os.path.dirname(sys.argv[0]),
                         "trac/versioncontrol/tests/svnrepos.dump"))
        try:
            dsp = DumpStreamParserSubclass()
            ptr, baton = repos.make_parse_fns3(dsp)
            self.assertRaises(TypeError, repos.parse_dumpstream3, stream, ptr,
                              baton, False, None)
        finally:
            stream.close()
Beispiel #4
0
    def test_parse_fns3(self):
        self.cancel_calls = 0

        def is_cancelled():
            self.cancel_calls += 1
            return None

        dump_path = os.path.join(os.path.dirname(sys.argv[0]),
                                 "trac/versioncontrol/tests/svnrepos.dump")
        stream = open(dump_path)
        dsp = DumpStreamParser()
        ptr, baton = repos.make_parse_fns3(dsp)
        repos.parse_dumpstream3(stream, ptr, baton, False, is_cancelled)
        stream.close()
        self.assertEqual(self.cancel_calls, 76)
        expected_list = [
            ("magic-header", 2),
            ('uuid', '92ea810a-adf3-0310-b540-bef912dcf5ba'),
            ('new-revision', 0),
            ('set-revision-prop', 0, 'svn:date',
             '2005-04-01T09:57:41.312767Z'),
            ('close-revision', 0),
            ('new-revision', 1),
            ('set-revision-prop', 1, 'svn:log', 'Initial directory layout.'),
            ('set-revision-prop', 1, 'svn:author', 'john'),
            ('set-revision-prop', 1, 'svn:date',
             '2005-04-01T10:00:52.353248Z'),
            ('new-node', 1, 'branches'),
            ('remove-node-props', 1, 'branches'),
            ('close-node', 1, 'branches'),
            ('new-node', 1, 'tags'),
            ('remove-node-props', 1, 'tags'),
            ('close-node', 1, 'tags'),
            ('new-node', 1, 'trunk'),
            ('remove-node-props', 1, 'trunk'),
            ('close-node', 1, 'trunk'),
            ('close-revision', 1),
            ('new-revision', 2),
            ('set-revision-prop', 2, 'svn:log', 'Added README.'),
            ('set-revision-prop', 2, 'svn:author', 'john'),
            ('set-revision-prop', 2, 'svn:date',
             '2005-04-01T13:12:18.216267Z'),
            ('new-node', 2, 'trunk/README.txt'),
            ('remove-node-props', 2, 'trunk/README.txt'),
            ('set-fulltext', 2, 'trunk/README.txt'),
            ('close-node', 2, 'trunk/README.txt'),
            ('close-revision', 2),
            ('new-revision', 3),
            ('set-revision-prop', 3, 'svn:log', 'Fixed README.\n'),
            ('set-revision-prop', 3, 'svn:author', 'kate'),
            ('set-revision-prop', 3, 'svn:date',
             '2005-04-01T13:24:58.234643Z'),
            ('new-node', 3, 'trunk/README.txt'),
            ('remove-node-props', 3, 'trunk/README.txt'),
            ('set-node-prop', 3, 'trunk/README.txt', 'svn:mime-type',
             'text/plain'),
            ('set-node-prop', 3, 'trunk/README.txt', 'svn:eol-style',
             'native'),
            ('set-fulltext', 3, 'trunk/README.txt'),
            ('close-node', 3, 'trunk/README.txt'),
            ('close-revision', 3),
        ]
        # Compare only the first X nodes described in the expected list - otherwise
        # the comparison list gets too long.
        self.assertEqual(dsp.ops[:len(expected_list)], expected_list)