Offline Server  1.6
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
test_make_incremental_updates.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 import unittest
4 import make_incremental_updates as mkup
5 from make_incremental_updates import PatchInfo, MarFileEntry
6 
7 class TestPatchInfo(unittest.TestCase):
8  def setUp(self):
9  self.work_dir = 'work_dir'
10  self.file_exclusion_list = ['channel-prefs.js','update.manifest','updatev2.manifest','removed-files']
11  self.path_exclusion_list = ['/readme.txt']
13 
14  def testPatchInfo(self):
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)
19  self.assertEquals(self.file_exclusion_list, self.patch_info.file_exclusion_list)
20  self.assertEquals(self.path_exclusion_list, self.patch_info.path_exclusion_list)
21 
23  self.patch_info.append_add_instruction('file.test')
24  self.assertEquals(['add "file.test"'], self.patch_info.manifestv1)
25 
27  self.patch_info.append_patch_instruction('file.test', 'patchname')
28  self.assertEquals(['patch "patchname" "file.test"'], self.patch_info.manifestv1)
29 
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)
34 
35  def test_create_manifest_file(self):
36  self.patch_info.create_manifest_file()
37  """
38 
40  self.assertEquals(({}, set([]), set([])), self.patch_info.build_marfile_entry_hash('root_path'))
41 
42 """ FIXME touches the filesystem, need refactoring
43 class TestMarFileEntry(unittest.TestCase):
44  def setUp(self):
45  root_path = '.'
46  self.filename = 'file.test'
47  f = open(self.filename, 'w')
48  f.write('Test data\n')
49  f.close()
50  self.mar_file_entry = MarFileEntry(root_path, self.filename)
51 
52  def test_calc_file_sha_digest(self):
53  f = open('test.sha', 'r')
54  goodSha = f.read()
55  f.close()
56  sha = self.mar_file_entry.calc_file_sha_digest(self.filename)
57  self.assertEquals(goodSha, sha)
58 
59  def test_sha(self):
60  f = open('test.sha', 'r')
61  goodSha = f.read()
62  f.close()
63  sha = self.mar_file_entry.sha()
64  self.assertEquals(goodSha, sha)
65 """
66 
67 class TestMakeIncrementalUpdates(unittest.TestCase):
68  def setUp(self):
69  work_dir = '.'
70  self.patch_info = PatchInfo(work_dir, ['channel-prefs.js','update.manifest','updatev2.manifest','removed-files'],['/readme.txt'])
71  root_path = '/'
72  filename = 'test.file'
73  self.mar_file_entry = MarFileEntry(root_path, filename)
74 
75  """ FIXME makes direct shell calls, need refactoring
76  def test_exec_shell_cmd(self):
77  mkup.exec_shell_cmd('echo test')
78 
79  def test_copy_file(self):
80  mkup.copy_file('src_file_abs_path', 'dst_file_abs_path')
81 
82  def test_bzip_file(self):
83  mkup.bzip_file('filename')
84 
85  def test_bunzip_file(self):
86  mkup.bunzip_file('filename')
87 
88  def test_extract_mar(self):
89  mkup.extract_mar('filename', 'work_dir')
90 
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)
93 
94  def test_create_add_patch_for_file(self):
95  mkup.create_add_patch_for_file('to_marfile_entry', self.patch_info)
96 
97  def test_process_explicit_remove_files(self):
98  mkup.process_explicit_remove_files('dir_path', self.patch_info)
99 
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')
102 
103  def test_create_partial_patches(patches):
104  mkup.create_partial_patches('patches')
105 
106  """
107 
108  """ FIXME touches the filesystem, need refactoring
109  def test_get_buildid(self):
110  mkup.get_buildid('work_dir', 'platform')
111  """
112 
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')
117 
118 if __name__ == '__main__':
119  unittest.main()
← centre documentaire © anakeen - published under CC License - Dynacase