def test_storeFetch(self): key = "storekey-" + self._token store = HDStore() store.store(key, self._data) data = store.fetch(key) self.assertEqual(self._data, data) # Verify data is not cached data = store._Cache.read(key) self.assertEqual(data, None) # Verify data is on disk exists = os.path.isfile(os.path.join(store._directory, key + ".json")) self.assertTrue(exists)
def test_storeFetch(self): key = 'storekey-' + self._token store = HDStore() store.store(key, self._data) data = store.fetch(key) self.assertEqual(self._data, data) # Verify data is not cached data = store._Cache.read(key) self.assertEqual(data, None) # Verify data is on disk exists = os.path.isfile(os.path.join(store._directory, key + '.json')) self.assertTrue(exists)
def test_moveIn(self): store = HDStore({"config": {"filesdir": "/tmp/hd40test"}}) store.purge() deviceA = store.read("Device_" + str(self._deviceA["_id"])) self.assertEqual(None, deviceA) # Save dict as Json - try moving it into the store, then fetching it back out. fileName = "Device_" + str(self._deviceA["_id"]) + ".json" jsonFile = open(fileName, "w") jsonFile.write(json.dumps(self._deviceA)) jsonFile.close() store.moveIn(fileName, fileName) deviceA = store.fetch("Device_" + str(self._deviceA["_id"])) self.assertEqual(self._deviceA, deviceA) # Cleanup store.purge() pass
def test_moveIn(self): store = HDStore({'config': {'filesdir': '/tmp/hd40test'}}) store.purge() deviceA = store.read('Device_' + str(self._deviceA['_id'])) self.assertEqual(None, deviceA) # Save dict as Json - try moving it into the store, then fetching it back out. fileName = 'Device_' + str(self._deviceA['_id']) + '.json' jsonFile = open(fileName, "w") jsonFile.write(json.dumps(self._deviceA)) jsonFile.close() store.moveIn(fileName, fileName) deviceA = store.fetch('Device_' + str(self._deviceA['_id'])) self.assertEqual(self._deviceA, deviceA) # Cleanup store.purge() pass