4 import make_incremental_updates
as mkup
5 from make_incremental_updates
import PatchInfo, MarFileEntry
15 self.assertEquals(self.
work_dir, self.patch_info.work_dir)
16 self.assertEquals([], self.patch_info.archive_files)
17 self.assertEquals([], self.patch_info.manifestv1)
18 self.assertEquals([], self.patch_info.manifestv2)
23 self.patch_info.append_add_instruction(
'file.test')
24 self.assertEquals([
'add "file.test"'], self.patch_info.manifestv1)
27 self.patch_info.append_patch_instruction(
'file.test',
'patchname')
28 self.assertEquals([
'patch "patchname" "file.test"'], self.patch_info.manifestv1)
30 """ FIXME touches the filesystem, need refactoring
31 def test_append_remove_instruction(self):
32 self.patch_info.append_remove_instruction('file.test')
33 self.assertEquals(['remove "file.test"'], self.patch_info.manifestv1)
35 def test_create_manifest_file(self):
36 self.patch_info.create_manifest_file()
40 self.assertEquals(({}, set([]), set([])), self.patch_info.build_marfile_entry_hash(
'root_path'))
42 """ FIXME touches the filesystem, need refactoring
43 class TestMarFileEntry(unittest.TestCase):
46 self.filename = 'file.test'
47 f = open(self.filename, 'w')
48 f.write('Test data\n')
50 self.mar_file_entry = MarFileEntry(root_path, self.filename)
52 def test_calc_file_sha_digest(self):
53 f = open('test.sha', 'r')
56 sha = self.mar_file_entry.calc_file_sha_digest(self.filename)
57 self.assertEquals(goodSha, sha)
60 f = open(
'test.sha',
'r')
63 sha = self.mar_file_entry.sha()
64 self.assertEquals(goodSha, sha)
67 class TestMakeIncrementalUpdates(unittest.TestCase):
70 self.patch_info = PatchInfo(work_dir, ['channel-prefs.js','update.manifest','updatev2.manifest','removed-files'],['/readme.txt'])
72 filename = 'test.file'
73 self.mar_file_entry = MarFileEntry(root_path, filename)
75 """ FIXME makes direct shell calls, need refactoring
76 def test_exec_shell_cmd(self):
77 mkup.exec_shell_cmd(
'echo test')
79 def test_copy_file(self):
80 mkup.copy_file(
'src_file_abs_path',
'dst_file_abs_path')
82 def test_bzip_file(self):
83 mkup.bzip_file(
'filename')
85 def test_bunzip_file(self):
86 mkup.bunzip_file(
'filename')
88 def test_extract_mar(self):
89 mkup.extract_mar(
'filename',
'work_dir')
91 def test_create_partial_patch_for_file(self):
92 mkup.create_partial_patch_for_file(
'from_marfile_entry',
'to_marfile_entry',
'shas', self.
patch_info)
94 def test_create_add_patch_for_file(self):
95 mkup.create_add_patch_for_file(
'to_marfile_entry', self.
patch_info)
97 def test_process_explicit_remove_files(self):
98 mkup.process_explicit_remove_files(
'dir_path', self.
patch_info)
100 def test_create_partial_patch(self):
101 mkup.create_partial_patch(
'from_dir_path',
'to_dir_path',
'patch_filename',
'shas', self.
patch_info,
'forced_updates')
103 def test_create_partial_patches(patches):
104 mkup.create_partial_patches(
'patches')
108 """ FIXME touches the filesystem, need refactoring
109 def test_get_buildid(self):
110 mkup.get_buildid(
'work_dir',
'platform')
113 def test_decode_filename(self):
114 expected = {'locale': 'lang', 'platform': 'platform', 'product': 'product', 'version': '1.0', 'type': 'complete'}
115 self.assertEquals(expected, mkup.decode_filename('product-1.0.lang.platform.complete.mar'))
116 self.assertRaises(Exception, mkup.decode_filename, 'fail')
118 if __name__ == '__main__':
def test_build_marfile_entry_hash
def test_append_add_instruction
def test_append_patch_instruction