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 """)
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 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_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_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 """ )
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 test_fix_content_length_text(self): lump = SvnLump() lump.set_header("Node-kind", "file") lump.set_header("Text-content-length", "3") 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("Content-length"), "3")
def test_fix_content_length_text(self): lump = SvnLump() lump.set_header('Node-kind', 'file') lump.set_header('Text-content-length', '3') 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('Content-length'), '3')
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'))