def test_singleFileImportList(self): print("Loading a list of single files") db = gcdb.readFiles([singleFilePath_1, singleFilePath_2]) # compare whether the loaded document matches the document in the data base self.assertEqual( gcdb.readFiles(singleFilePath_2).get(doc_id=1), db.get(doc_id=2)) db.close() # not really needed as not writing to file print("--> OK")
def test_singleFileImport2Json(self): print("Loading a single data point into json storage data base") db = gcdb.readFiles(singleFilePath_1, store=testdbString) with open(testdbString) as dbFile: # compare whether the loaded document matches the stored document self.assertEqual( gcdb.readFiles(singleFilePath_1).get(doc_id=1), json.load(dbFile)['_default']['1']) db.close() os.remove(testdbString) print("--> OK")
def test_singleFileImportPassingDB(self): print("Loading a second data point into an existing data base") db = gcdb.readFiles(singleFilePath_1, store=testdbString) db = gcdb.readFiles(singleFilePath_2, db=db) # compare whether the loaded document matches the stored document self.assertTrue(len(db) == 2) self.assertEqual(db.get(doc_id=2), gcdb.readFiles(singleFilePath_2).get(doc_id=1)) db.close() os.remove(testdbString) print("--> OK")
def test_singleFileImportOverwrite(self): print( "Loading two data points into json storage data base with overwrite mode" ) db = gcdb.readFiles(singleFilePath_1, store=testdbString) db.close() db = gcdb.readFiles(singleFilePath_2, store=testdbString) # compare whether the loaded document matches the stored document self.assertTrue(len(db) == 1) self.assertEqual(db.get(doc_id=1), gcdb.readFiles(singleFilePath_2).get(doc_id=1)) db.close() os.remove(testdbString) print("--> OK")
def test_singleFileImport2Memory(self): print("Loading a single data point into memory data base") # load the specified file using the function db = gcdb.readFiles(singleFilePath_1) # compare whether it actually maches the imported file as json structure with open(singleFilePath_1) as testFile: data2compare = json.load(testFile) data2compare.update({'filename': singleFilePath_1}) self.assertEqual(db.get(doc_id=1), data2compare) print("--> OK")