63 files2.sort() |
63 files2.sort() |
64 for i in range(len(files1)): |
64 for i in range(len(files1)): |
65 self.assertEquals(files1[i],files2[i]) |
65 self.assertEquals(files1[i],files2[i]) |
66 os.unlink(export_zip) |
66 os.unlink(export_zip) |
67 |
67 |
|
68 def test_export_with_include_content_filter(self): |
|
69 include_content_filter = ".*layer4.*" |
|
70 include_filters = {'content':include_content_filter} |
|
71 test_project_dir = os.path.join(temp_dir, "test_project_1") |
|
72 unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) |
|
73 |
|
74 export_zip = os.path.join(temp_dir, "configexport.zip") |
|
75 |
|
76 fs = FileStorage(test_project_dir) |
|
77 p = api.Project(fs) |
|
78 conf = p.get_configuration('root5.confml') |
|
79 zs = ZipStorage(export_zip,"w") |
|
80 zp = api.Project(zs) |
|
81 p.export_configuration(conf,zs,include_filters = include_filters) |
|
82 zp.close() |
|
83 |
|
84 zs = ZipStorage(export_zip,"r") |
|
85 zp = api.Project(zs) |
|
86 conf = zp.get_configuration('root5.confml') |
|
87 rel = conf.get_layer().list_all_related() |
|
88 |
|
89 exp = ['Layer1/implml/bitmask_test_12341002.crml', |
|
90 'Layer1/implml/feature1_12341000.crml', |
|
91 'Layer1/implml/feature1_12341001.crml', |
|
92 'Layer1/implml/feature1_sequence.gcfml', |
|
93 'Layer1/implml/feature2_ABCD0000.crml', |
|
94 'Layer1/implml/time_types_test_12341003.crml', |
|
95 'Layer4/content/seq/layer4_file.txt'] |
|
96 zs.close() |
|
97 self.assertEquals(exp,rel) |
|
98 os.unlink(export_zip) |
|
99 |
|
100 def test_export_with_exclude_content_filter(self): |
|
101 exclude_content_filter = ".*(layer1|layer2).*" |
|
102 exclude_filters = {'content':exclude_content_filter} |
|
103 test_project_dir = os.path.join(temp_dir, "test_project_1") |
|
104 unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) |
|
105 |
|
106 export_zip = os.path.join(temp_dir, "configexport.zip") |
|
107 |
|
108 fs = FileStorage(test_project_dir) |
|
109 p = api.Project(fs) |
|
110 conf = p.get_configuration('root5.confml') |
|
111 zs = ZipStorage(export_zip,"w") |
|
112 zp = api.Project(zs) |
|
113 p.export_configuration(conf,zs,exclude_filters = exclude_filters) |
|
114 zp.close() |
|
115 |
|
116 zs = ZipStorage(export_zip,"r") |
|
117 zp = api.Project(zs) |
|
118 conf = zp.get_configuration('root5.confml') |
|
119 rel = conf.get_layer().list_all_related() |
|
120 |
|
121 exp = ['Layer1/implml/bitmask_test_12341002.crml', |
|
122 'Layer1/implml/feature1_12341000.crml', |
|
123 'Layer1/implml/feature1_12341001.crml', |
|
124 'Layer1/implml/feature1_sequence.gcfml', |
|
125 'Layer1/implml/feature2_ABCD0000.crml', |
|
126 'Layer1/implml/time_types_test_12341003.crml', |
|
127 'Layer3/content/seq/layer3_file.txt', |
|
128 'Layer4/content/seq/layer4_file.txt', |
|
129 'Layer5/content/content.txt', |
|
130 'Layer5/content/folder/abc.txt'] |
|
131 zs.close() |
|
132 self.assertEquals(exp,rel) |
|
133 os.unlink(export_zip) |
|
134 |
|
135 def test_export_with_include_exclude_content_filters(self): |
|
136 exclude_content_filter = ".*def.+\.txt" |
|
137 include_content_filter = ".*layer5.*" |
|
138 exclude_filters = {'content':exclude_content_filter} |
|
139 include_filters = {'content':include_content_filter} |
|
140 test_project_dir = os.path.join(temp_dir, "test_project_1") |
|
141 unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) |
|
142 |
|
143 export_zip = os.path.join(temp_dir, "configexport.zip") |
|
144 |
|
145 fs = FileStorage(test_project_dir) |
|
146 p = api.Project(fs) |
|
147 conf = p.get_configuration('root5.confml') |
|
148 zs = ZipStorage(export_zip,"w") |
|
149 zp = api.Project(zs) |
|
150 p.export_configuration(conf,zs,exclude_filters = exclude_filters, |
|
151 include_filters = include_filters) |
|
152 zp.close() |
|
153 |
|
154 zs = ZipStorage(export_zip,"r") |
|
155 zp = api.Project(zs) |
|
156 conf = zp.get_configuration('root5.confml') |
|
157 rel = conf.get_layer().list_all_related() |
|
158 |
|
159 exp = ['Layer1/implml/bitmask_test_12341002.crml', |
|
160 'Layer1/implml/feature1_12341000.crml', |
|
161 'Layer1/implml/feature1_12341001.crml', |
|
162 'Layer1/implml/feature1_sequence.gcfml', |
|
163 'Layer1/implml/feature2_ABCD0000.crml', |
|
164 'Layer1/implml/time_types_test_12341003.crml', |
|
165 'Layer5/content/content.txt', |
|
166 'Layer5/content/folder/abc.txt'] |
|
167 |
|
168 zs.close() |
|
169 self.assertEquals(exp,rel) |
|
170 os.unlink(export_zip) |
|
171 |
68 def test_export_from_files_to_zipstorage_add(self): |
172 def test_export_from_files_to_zipstorage_add(self): |
69 test_project_dir = os.path.join(temp_dir, "test_project_1") |
173 test_project_dir = os.path.join(temp_dir, "test_project_1") |
70 unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) |
174 unzip_file.unzip_file(test_cpf, test_project_dir, delete_if_exists=True) |
71 |
175 |
72 export_zip = os.path.join(temp_dir, "configexport2.zip") |
176 export_zip = os.path.join(temp_dir, "configexport2.zip") |
156 p.export_configuration(conf,fs) |
260 p.export_configuration(conf,fs) |
157 p.close() |
261 p.close() |
158 r.close() |
262 r.close() |
159 self.assertTrue(os.path.exists(output_dir)) |
263 self.assertTrue(os.path.exists(output_dir)) |
160 |
264 |
161 # Temporarly hacked to pass, because feature is not supported |
|
162 # def test_export_to_zipstorage_multiple_configurations(self): |
|
163 # try: |
|
164 # fs = FileStorage(datafolder) |
|
165 # p = api.Project(fs) |
|
166 # zs = ZipStorage(tempzip,"w") |
|
167 # zp = api.Project(zs) |
|
168 # conf = p.get_configuration('morestuff.confml') |
|
169 # conf_files = conf.list_resources() |
|
170 # p.export_configuration(conf,zs) |
|
171 # conf = p.get_configuration('prodX.confml') |
|
172 # conf_files2 = conf.list_resources() |
|
173 # conf_files.extend(conf_files2) |
|
174 # conf_files = utils.distinct_array(conf_files) |
|
175 # p.export_configuration(conf,zs) |
|
176 # zp.close() |
|
177 # self.assertTrue(os.path.exists(tempzip)) |
|
178 # zfile = zipfile.ZipFile(tempzip,"r") |
|
179 # files = zfile.namelist() |
|
180 # files.remove('.metadata') |
|
181 # self.assertEquals(sorted(conf_files),sorted(files)) |
|
182 # except exceptions.NotSupportedException: |
|
183 # pass |
|
184 |
265 |
185 def _test_export_to_filestorage_multiple_configurations(self): |
266 def _test_export_to_filestorage_multiple_configurations(self): |
186 fs = FileStorage(datafolder) |
267 fs = FileStorage(datafolder) |
187 p = api.Project(fs) |
268 p = api.Project(fs) |
188 fs2 = FileStorage(os.path.join(temp_dir,"multiple"),"w") |
269 fs2 = FileStorage(os.path.join(temp_dir,"multiple"),"w") |