def test_storage_pickle(self): p = os.path.join(self.test_path, "test.kg") bucket = Bucket(storage_format="pickle", storage_path=p) bucket.zoo.insert(dict(animal="lion", number=2)) bucket.zoo.insert(dict(animal="kangaroo", number=100)) bucket.flush() self.assertTrue(os.path.exists(p)) bucket = Bucket(storage_format="pickle", storage_path=p) self.assertEqual(len(bucket.zoo.find_all()), 2) f = dict(number=2) self.assertEqual(bucket.zoo.find(**f).number, 2)
def test_storage_pickle(self): p = os.path.join(self.test_path, "test.kg") bucket = Bucket(storage_format="pickle", storage_path=p) bucket.zoo.insert(dict(animal="lion", number=2)) bucket.zoo.insert(dict(animal="kangaroo", number=100)) bucket.flush() self.assertTrue(os.path.exists(p)) bucket = Bucket(storage_format="pickle", storage_path=p) self.assertEqual(len(bucket.zoo.find_all()), 2) f = dict(number=2) self.assertEqual(bucket.zoo.find(**f).number, 2)
def test_storage_csv(self): p = os.path.join(self.test_path, "test.kg") bucket = Bucket(storage_format="csv", storage_path=p, storage_options=dict(use_first_row_as_column_name=True)) bucket.zoo.insert(dict(animal="lion", number=2)) bucket.zoo.insert(dict(animal="kangaroo", number=100)) bucket.flush() self.assertTrue(os.path.exists(p)) bucket = Bucket(storage_format="csv", storage_path=p, storage_options=dict( use_first_row_as_column_name=True, table_name="zoo")) self.assertEqual(len(bucket.zoo.find_all()), 2) f = dict(number="2") self.assertEqual(bucket.zoo.find(**f).number, "2")
def test_storage_csv(self): p = os.path.join(self.test_path, "test.kg") bucket = Bucket( storage_format="csv", storage_path=p, storage_options=dict(use_first_row_as_column_name=True)) bucket.zoo.insert(dict(animal="lion", number=2)) bucket.zoo.insert(dict(animal="kangaroo", number=100)) bucket.flush() self.assertTrue(os.path.exists(p)) bucket = Bucket(storage_format="csv", storage_path=p, storage_options=dict(use_first_row_as_column_name=True, table_name="zoo")) self.assertEqual(len(bucket.zoo.find_all()), 2) f = dict(number="2") self.assertEqual(bucket.zoo.find(**f).number, "2")
def test_flush_no_storage(self): bucket = Bucket(storage_format=None) bucket.zoo.insert(dict(animal="lion", number=2)) bucket.zoo.insert(dict(animal="kangaroo", number=100)) bucket.flush()
def test_flush_no_storage(self): bucket = Bucket(storage_format=None) bucket.zoo.insert(dict(animal="lion", number=2)) bucket.zoo.insert(dict(animal="kangaroo", number=100)) bucket.flush()