Пример #1
0
    def test_properties_only(self):
        lump = SvnLump()
        lump.set_header('header1', 'value1')
        lump.set_header('header2', 'value2')
        lump.properties['prop1'] = "zzz\nyyy\n"
        lump.properties['second_property'] = 'abc'

        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(self.output.read(), """header1: value1
header2: value2

K 5
prop1
V 8
zzz
yyy

K 15
second_property
V 3
abc
PROPS-END

"""
        )
Пример #2
0
    def test_fix_content_length_prop_no_old(self):
        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        lump.properties = { 'blub': 'XXX' }

        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 1)
        self.assertEqual(self.writer.lumps[0].get_header('Prop-content-length'), '27')
        self.assertEqual(self.writer.lumps[0].get_header('Content-length'), '27')
    def test_fix_content_length_prop_no_old(self):
        lump = SvnLump()
        lump.set_header("Node-kind", "file")
        lump.properties = {"blub": "XXX"}

        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 1)
        self.assertEqual(self.writer.lumps[0].get_header("Prop-content-length"), "27")
        self.assertEqual(self.writer.lumps[0].get_header("Content-length"), "27")
Пример #4
0
    def test_fix_content_length_prop_no_old(self):
        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        lump.properties = {'blub': 'XXX'}

        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 1)
        self.assertEqual(self.writer.lumps[0].get_header('Prop-content-length'), '27')
        self.assertEqual(self.writer.lumps[0].get_header('Content-length'), '27')
Пример #5
0
    def test_create_parent_dirs(self):
        self.config.create_parent_dirs = True

        lump = SvnLump()
        lump.set_header('Revision-number', '12')
        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 3)
        self.assertEqual(self.writer.lumps[0].get_header('Revision-number'), '12')
        self.assertEqual(self.writer.lumps[1].get_header('ParentDirectoryGeneratorMockLump'), '1of2')
        self.assertEqual(self.writer.lumps[2].get_header('ParentDirectoryGeneratorMockLump'), '2of2')
    def test_create_parent_dirs(self):
        self.config.create_parent_dirs = True

        lump = SvnLump()
        lump.set_header("Revision-number", "12")
        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 3)
        self.assertEqual(self.writer.lumps[0].get_header("Revision-number"), "12")
        self.assertEqual(self.writer.lumps[1].get_header("ParentDirectoryGeneratorMockLump"), "1of2")
        self.assertEqual(self.writer.lumps[2].get_header("ParentDirectoryGeneratorMockLump"), "2of2")
Пример #7
0
    def test_simple(self):
        lump = SvnLump()
        lump.set_header('header1', 'value1')
        lump.set_header('header2', 'value2')

        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(self.output.read(), """header1: value1
header2: value2

""")
Пример #8
0
    def test_pass_lump(self):
        sample_lump = SvnLump()
        sample_lump.set_header('Marker', 'abc')

        self.builder.pass_lump(sample_lump)

        self.assertEqual(len(self.writer.lumps), 1)
        lump = self.writer.lumps[0]
        self.assertEqual(lump.get_header_keys(), ['Marker'])
        self.assertEqual(lump.get_header('Marker'), 'abc')
        self.assertEqual(lump.properties, {})
        self.writer.check_content_tin_of_lump_nr(0, None)
Пример #9
0
    def test_simple(self):
        lump = SvnLump()
        lump.set_header('header1', 'value1')
        lump.set_header('header2', 'value2')

        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(self.output.read(), """header1: value1
header2: value2

"""
        )
Пример #10
0
    def test_pass_lump(self):
        sample_lump = SvnLump()
        sample_lump.set_header('Marker', 'abc')

        self.builder.pass_lump(sample_lump)

        self.assertEqual(len(self.writer.lumps), 1)
        lump = self.writer.lumps[0]
        self.assertEqual(
            lump.get_header_keys(),
            [ 'Marker' ]
        )
        self.assertEqual(lump.get_header('Marker'), 'abc')
        self.assertEqual(lump.properties, { })
        self.writer.check_content_tin_of_lump_nr(0, None)
Пример #11
0
    def test_drop_empty_revs(self):
        lump = SvnLump()
        lump.set_header('Revision-number', '12')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Revision-number', '13')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 2)
        self.assertEqual(self.writer.lumps[0].get_header('Revision-number'), '13')
        self.assertEqual(self.writer.lumps[1].get_header('Node-kind'), 'file')
    def test_drop_empty_revs(self):
        lump = SvnLump()
        lump.set_header("Revision-number", "12")
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header("Revision-number", "13")
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header("Node-kind", "file")
        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 2)
        self.assertEqual(self.writer.lumps[0].get_header("Revision-number"), "13")
        self.assertEqual(self.writer.lumps[1].get_header("Node-kind"), "file")
Пример #13
0
    def test_fix_content_length_text_and_prop(self):
        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        lump.set_header('Text-content-length', '3')
        lump.properties = { 'blub': 'XXX' }
        fh = StringIO('bla')
        lump.content = ContentTin(fh, 3, 'FAKE-MD5SUM')

        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 1)
        self.assertEqual(self.writer.lumps[0].get_header('Text-content-length'), '3')
        self.assertEqual(self.writer.lumps[0].get_header('Prop-content-length'), '27')
        self.assertEqual(self.writer.lumps[0].get_header('Content-length'), '30')
Пример #14
0
    def test_properties_only(self):
        lump = SvnLump()
        lump.set_header('header1', 'value1')
        lump.set_header('header2', 'value2')
        lump.properties['prop1'] = "zzz\nyyy\n"
        lump.properties['second_property'] = 'abc'

        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(
            self.output.read(), """header1: value1
header2: value2

K 5
prop1
V 8
zzz
yyy

K 15
second_property
V 3
abc
PROPS-END

""")
    def test_fix_content_length_text_and_prop(self):
        lump = SvnLump()
        lump.set_header("Node-kind", "file")
        lump.set_header("Text-content-length", "3")
        lump.properties = {"blub": "XXX"}
        fh = StringIO("bla")
        lump.content = ContentTin(fh, 3, "FAKE-MD5SUM")

        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 1)
        self.assertEqual(self.writer.lumps[0].get_header("Text-content-length"), "3")
        self.assertEqual(self.writer.lumps[0].get_header("Prop-content-length"), "27")
        self.assertEqual(self.writer.lumps[0].get_header("Content-length"), "30")
Пример #16
0
    def test_fix_content_length_text_and_prop(self):
        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        lump.set_header('Text-content-length', '3')
        lump.properties = {'blub': 'XXX'}
        fh = StringIO('bla')
        lump.content = ContentTin(fh, 3, 'FAKE-MD5SUM')

        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 1)
        self.assertEqual(self.writer.lumps[0].get_header('Text-content-length'), '3')
        self.assertEqual(self.writer.lumps[0].get_header('Prop-content-length'), '27')
        self.assertEqual(self.writer.lumps[0].get_header('Content-length'), '30')
Пример #17
0
    def test_clone_change_lump_from_add_lump(self):
        sample_lump = SvnLump()
        sample_lump.set_header('Node-path', 'a/b/c')
        sample_lump.set_header('Node-kind', 'file')
        sample_lump.set_header('Node-action', 'add')
        sample_lump.set_header('Text-content-length', '3')
        sample_lump.set_header('Text-content-md5', 'FAKEMD5')
        sample_lump.set_header('Node-copyfrom-path', 'blubber')
        sample_lump.set_header('Node-copyfrom-rev', '2')
        sample_lump.properties =  { 'a': 'x1', 'b': 'x2' }
        sample_fh = StringIO("abcXXX")
        sample_tin = ContentTin(sample_fh, 3, 'FAKEMD5')
        sample_lump.content = sample_tin

        self.builder.change_lump_from_add_or_replace_lump(sample_lump)

        self.assertEqual(len(self.writer.lumps), 1)
        lump = self.writer.lumps[0]
        self.assertEqual(
            lump.get_header_keys(),
            [ 'Node-path', 'Node-action', 'Text-content-length', 'Text-content-md5' ]
        )
        self.assertEqual(lump.get_header('Node-path'), 'a/b/c')
        self.assertEqual(lump.get_header('Node-action'), 'change')
        self.assertEqual(lump.get_header('Text-content-length'), '3')
        self.assertEqual(lump.get_header('Text-content-md5'), 'FAKEMD5')
        self.assertEqual(lump.properties, { 'a': 'x1', 'b': 'x2' } )
        self.writer.check_content_tin_of_lump_nr(0, 'abc')
 def write_lumps(self):
     for marker in ["1of2", "2of2"]:
         lump = SvnLump()
         lump.set_header("ParentDirectoryGeneratorMockLump", marker)
         self.writer.write_lump(lump)
Пример #19
0
    def test_text_only(self):
        lump = SvnLump()
        lump.set_header('Node-path', 'a')
        lump.set_header('Node-kind', 'file')
        lump.set_header('Node-action', 'change')
        lump.set_header('Text-content-length', '2')
        lump.set_header('Text-content-md5', '009520053b00386d1173f3988c55d192')
        lump.set_header('Text-content-sha1', '9063a9f0e032b6239403b719cbbba56ac4e4e45f')
        lump.set_header('Content-length', 2)
        content_fh = StringIO("y\n")
        lump.content = ContentTin(content_fh, 2, '009520053b00386d1173f3988c55d192')
        
        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(self.output.read(), """Node-path: a
Node-kind: file
Node-action: change
Text-content-length: 2
Text-content-md5: 009520053b00386d1173f3988c55d192
Text-content-sha1: 9063a9f0e032b6239403b719cbbba56ac4e4e45f
Content-length: 2

y


"""
        )
Пример #20
0
    def test_map_dropped_revs(self):
        lump = SvnLump()
        lump.set_header('Revision-number', '12')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        self.processor.write_lump(lump)

        # Dropped rev
        lump = SvnLump()
        lump.set_header('Revision-number', '13')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Revision-number', '14')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        lump.set_header('Node-copyfrom-rev', '13')
        self.processor.write_lump(lump)


        self.assertEqual(len(self.writer.lumps), 4)
        self.assertEqual(self.writer.lumps[2].get_header('Revision-number'), '14')
        self.assertEqual(self.writer.lumps[3].get_header('Node-copyfrom-rev'), '12')
Пример #21
0
    def test_text_only(self):
        lump = SvnLump()
        lump.set_header('Node-path', 'a')
        lump.set_header('Node-kind', 'file')
        lump.set_header('Node-action', 'change')
        lump.set_header('Text-content-length', '2')
        lump.set_header('Text-content-md5', '009520053b00386d1173f3988c55d192')
        lump.set_header('Text-content-sha1',
                        '9063a9f0e032b6239403b719cbbba56ac4e4e45f')
        lump.set_header('Content-length', 2)
        content_fh = StringIO("y\n")
        lump.content = ContentTin(content_fh, 2,
                                  '009520053b00386d1173f3988c55d192')

        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(
            self.output.read(), """Node-path: a
Node-kind: file
Node-action: change
Text-content-length: 2
Text-content-md5: 009520053b00386d1173f3988c55d192
Text-content-sha1: 9063a9f0e032b6239403b719cbbba56ac4e4e45f
Content-length: 2

y


""")
Пример #22
0
    def test_clone_change_lump_from_add_lump(self):
        sample_lump = SvnLump()
        sample_lump.set_header('Node-path', 'a/b/c')
        sample_lump.set_header('Node-kind', 'file')
        sample_lump.set_header('Node-action', 'add')
        sample_lump.set_header('Text-content-length', '3')
        sample_lump.set_header('Text-content-md5', 'FAKEMD5')
        sample_lump.set_header('Node-copyfrom-path', 'blubber')
        sample_lump.set_header('Node-copyfrom-rev', '2')
        sample_lump.properties = {'a': 'x1', 'b': 'x2'}
        sample_fh = StringIO("abcXXX")
        sample_tin = ContentTin(sample_fh, 3, 'FAKEMD5')
        sample_lump.content = sample_tin

        self.builder.change_lump_from_add_or_replace_lump(sample_lump)

        self.assertEqual(len(self.writer.lumps), 1)
        lump = self.writer.lumps[0]
        self.assertEqual(lump.get_header_keys(), [
            'Node-path', 'Node-action', 'Text-content-length',
            'Text-content-md5'
        ])
        self.assertEqual(lump.get_header('Node-path'), 'a/b/c')
        self.assertEqual(lump.get_header('Node-action'), 'change')
        self.assertEqual(lump.get_header('Text-content-length'), '3')
        self.assertEqual(lump.get_header('Text-content-md5'), 'FAKEMD5')
        self.assertEqual(lump.properties, {'a': 'x1', 'b': 'x2'})
        self.writer.check_content_tin_of_lump_nr(0, 'abc')
Пример #23
0
 def write_lumps(self):
     for marker in [ '1of2', '2of2' ]:
         lump = SvnLump()
         lump.set_header('ParentDirectoryGeneratorMockLump', marker)
         self.writer.write_lump(lump)
Пример #24
0
    def test_map_dropped_revs(self):
        lump = SvnLump()
        lump.set_header('Revision-number', '12')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        self.processor.write_lump(lump)

        # Dropped rev
        lump = SvnLump()
        lump.set_header('Revision-number', '13')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Revision-number', '14')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        lump.set_header('Node-copyfrom-rev', '13')
        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 4)
        self.assertEqual(self.writer.lumps[2].get_header('Revision-number'), '14')
        self.assertEqual(self.writer.lumps[3].get_header('Node-copyfrom-rev'), '12')
Пример #25
0
    def testSimpleLump(self):
        lump = SvnLump()
        lump.set_header('a_hdr', 'y')
        lump.set_header('c_hdr', 'z')
        lump.set_header('b_hdr', 'x')
        lump.set_header('d_hdr', 'x')
        lump.delete_header('b_hdr')
        lump.properties['prop_a'] = 'bla'
        lump.properties['prop_a'] = 'blub'
        lump.content = 'Something'

        self.assertEqual(lump.get_header_keys(), ['a_hdr', 'c_hdr', 'd_hdr'])
        self.assertEqual(lump.get_header('a_hdr'), 'y')
        self.assertEqual(lump.get_header('c_hdr'), 'z')
        self.assertEqual(lump.get_header('d_hdr'), 'x')
        self.assertTrue(lump.has_header('a_hdr'))
        self.assertFalse(lump.has_header('x_hdr'))
Пример #26
0
 def write_lumps(self):
     for marker in ['1of2', '2of2']:
         lump = SvnLump()
         lump.set_header('ParentDirectoryGeneratorMockLump', marker)
         self.writer.write_lump(lump)
Пример #27
0
    def test_text_and_properties(self):
        lump = SvnLump()
        lump.set_header('Node-path', 'bla')
        lump.set_header('Node-kind', 'file')
        lump.set_header('Node-action', 'add')
        lump.set_header('Text-content-length', 16)
        lump.properties['blub'] = "XXX"
        content_fh = StringIO("fsdfa\nfgasdfgsd\n")
        lump.content = ContentTin(content_fh, 16, 'FAKEMD5SUM')

        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(self.output.read(), """Node-path: bla
Node-kind: file
Node-action: add
Text-content-length: 16

K 4
blub
V 3
XXX
PROPS-END
fsdfa
fgasdfgsd


"""
        )
    def test_map_dropped_revs(self):
        lump = SvnLump()
        lump.set_header("Revision-number", "12")
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header("Node-kind", "file")
        self.processor.write_lump(lump)

        # Dropped rev
        lump = SvnLump()
        lump.set_header("Revision-number", "13")
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header("Revision-number", "14")
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header("Node-kind", "file")
        lump.set_header("Node-copyfrom-rev", "13")
        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 4)
        self.assertEqual(self.writer.lumps[2].get_header("Revision-number"), "14")
        self.assertEqual(self.writer.lumps[3].get_header("Node-copyfrom-rev"), "12")
Пример #29
0
    def test_drop_empty_revs(self):
        lump = SvnLump()
        lump.set_header('Revision-number', '12')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Revision-number', '13')
        self.processor.write_lump(lump)

        lump = SvnLump()
        lump.set_header('Node-kind', 'file')
        self.processor.write_lump(lump)

        self.assertEqual(len(self.writer.lumps), 2)
        self.assertEqual(self.writer.lumps[0].get_header('Revision-number'), '13')
        self.assertEqual(self.writer.lumps[1].get_header('Node-kind'), 'file')
Пример #30
0
    def testSimpleLump(self):
        lump = SvnLump()
        lump.set_header('a_hdr', 'y')
        lump.set_header('c_hdr', 'z')
        lump.set_header('b_hdr', 'x')
        lump.set_header('d_hdr', 'x')
        lump.delete_header('b_hdr')
        lump.properties['prop_a'] = 'bla'
        lump.properties['prop_a'] = 'blub'
        lump.content = 'Something'

        self.assertEqual(lump.get_header_keys(), ['a_hdr', 'c_hdr', 'd_hdr'])
        self.assertEqual(lump.get_header('a_hdr'), 'y')
        self.assertEqual(lump.get_header('c_hdr'), 'z')
        self.assertEqual(lump.get_header('d_hdr'), 'x')
        self.assertTrue(lump.has_header('a_hdr'))
        self.assertFalse(lump.has_header('x_hdr'))
Пример #31
0
    def test_text_and_properties(self):
        lump = SvnLump()
        lump.set_header('Node-path', 'bla')
        lump.set_header('Node-kind', 'file')
        lump.set_header('Node-action', 'add')
        lump.set_header('Text-content-length', 16)
        lump.properties['blub'] = "XXX"
        content_fh = StringIO("fsdfa\nfgasdfgsd\n")
        lump.content = ContentTin(content_fh, 16, 'FAKEMD5SUM')

        self.writer.write_lump(lump)

        self.output.seek(0)
        self.assertEqual(
            self.output.read(), """Node-path: bla
Node-kind: file
Node-action: add
Text-content-length: 16

K 4
blub
V 3
XXX
PROPS-END
fsdfa
fgasdfgsd


""")