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_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_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')
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_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")
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')
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')