def test_2_multiImport(self): # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() imp.do(doc) # autoload self.assertGreater(len(doc.data['0:hsm/sample0/h']), 10) # no load: ds present but empty self.assertIn('0:hsm/sample0/e', doc.available_data) self.assertNotIn('0:hsm/sample0/e', doc.data) imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4b)) imp.do(doc) self.assertIn('0:t', imp.outnames) self.assertIn('0:t', doc.data.keys())
def test_1_importFromM4(self): # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() imp.do(doc) # autoload self.assertGreater(len(doc.data['0:hsm/sample0/h']), 10) # no load: ds present but empty self.assertIn('0:hsm/sample0/e', doc.available_data) self.assertNotIn('0:hsm/sample0/e', doc.data) hidden_data = set([ '0:hsm/sample0/iC', '0:hsm/sample0/iB', '0:hsm/sample0/iA', '0:hsm/sample0/iD' ]) self.assertSetEqual( set(m4names) - set(imp.outnames) - set(doc.available_data.keys()), hidden_data) self.check_doc(doc, nativem4) # Test single dataset name import imp = filedata.OperationMisuraImport.from_dataset_in_file( '0:hsm/sample0/e', nativem4) imp.do(doc) self.assertIn('0:hsm/sample0/e', doc.data) self.assertNotIn('0:hsm/sample0/e', doc.available_data)
def test_import(self): imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() imp.do(doc) root = filedata.NodeEntry() root.set_doc(doc) for path, ds in doc.data.iteritems(): dataset_entry = root.traverse(path) self.assertEqual(ds, dataset_entry.ds)
def test_0_importFromM3(self): """Test the operation from a Misura3 file""" # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=from3)) doc = filedata.MisuraDocument() imp.do(doc) m3names = [ 't', 'kiln_T', 'smp0_Sint', 'smp0_Ang', 'smp0_Ratio', 'smp0_Area', 'kiln_S', 'kiln_P', 'smp0_Width' ] self.assertEqual(imp.outnames, m3names) self.check_doc(doc, from3)
def check_import(self, op, names=False): """Simulate a data import operation""" logging.debug('check_import', op) fp = indexer.SharedFile(op) fp.load_conf() rm = devtree.recursiveModel(fp.conf) fp.close() # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=op)) doc = filedata.MisuraDocument() imp.do(doc) # if names is not False: # self.assertEqual(set(imp.outdatasets), names) for ds in doc.data.itervalues(): self.assertFalse(np.isnan(ds.data).any()) return doc
def test(self): """Double import a file and subtract the same datasets.""" nativem4 = os.path.join(iut.data_dir, 'test_video.h5') # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) misuraDocument = filedata.MisuraDocument() self.cmd = document.CommandInterface(misuraDocument) plugin.makeDefaultDoc(self.cmd) imp.do(misuraDocument) # Import again imp.do(misuraDocument) misuraDocument.model.refresh() tree = misuraDocument.model.tree entry = tree.traverse('0:hsm/sample0') self.assertTrue(entry != False) self.do(misuraDocument, entry)
def test(self): # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=nativem4)) doc = filedata.MisuraDocument() self.cmd = document.CommandInterface(doc) plugin.makeDefaultDoc(self.cmd) imp.do(doc) fields = { 'd': 'summary/vertical/sample0/d', 'T': 'summary/kiln/T', 'std': 'NIST SRM738', 'start': 50, 'end': 50, 'label': 1, 'add': 1, 'currentwidget': '/' } p = plugin.CalibrationFactorPlugin() p.apply(self.cmd, fields) self.assertIn(fields['d'] + '_NIST_SRM738', doc.data) doc.model.refresh(force=True)
def test_init(self): fpath = os.path.join(iutils_testing.data_dir, 'test_video.h5') # Simulate an import imp = filedata.OperationMisuraImport( filedata.ImportParamsMisura(filename=fpath)) doc = filedata.MisuraDocument() imp.do(doc) fp = indexer.SharedFile(fpath) decoder = filedata.DataDecoder() profile = '/hsm/sample0/profile' decoder.reset(fp, profile) self.sync(decoder) doc.decoders[fpath+':'+profile] = decoder mini = fileui.MiniImage(doc, '/hsm/sample0/profile') mini.saveDir = iutils_testing.data_dir mini.set_idx(0) self.saved_file = mini.save_frame() self.assertTrue(os.path.exists(self.saved_file))