Beispiel #1
0
    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)
Beispiel #2
0
    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")
Beispiel #3
0
    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")
Beispiel #4
0
 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()
Beispiel #5
0
 def test_delete_table(self):
     bucket = Bucket()
     name = bucket.new_table.tbl_name 
     bucket.delete_table(name)
     self.assertEqual(len(bucket.tables), 0)