-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_columnar_storage.py
34 lines (26 loc) · 1.32 KB
/
test_columnar_storage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import unittest
from storage import ColumnarStorage
class TestColumnarStorage(unittest.TestCase):
def setUp(self):
self.storage = ColumnarStorage()
def test_add_column(self):
self.storage.add_column('name', ['Alice', 'Bob', 'Charlie'])
self.assertEqual(self.storage.get_column('name'), ['Alice', 'Bob', 'Charlie'])
def test_get_column(self):
self.storage.add_column('name', ['Alice', 'Bob', 'Charlie'])
self.assertEqual(self.storage.get_column('name'), ['Alice', 'Bob', 'Charlie'])
self.assertIsNone(self.storage.get_column('age'))
def test_remove_column(self):
self.storage.add_column('name', ['Alice', 'Bob', 'Charlie'])
self.storage.add_column('age', [25, 30, 35])
self.storage.remove_column('age')
self.assertIsNone(self.storage.get_column('age'))
self.assertEqual(self.storage.get_column('name'), ['Alice', 'Bob', 'Charlie'])
def test_compression(self):
self.storage.add_column('name', ['Alice', 'Bob', 'Charlie'])
compressed_data = self.storage.columns['name']
self.assertNotEqual(compressed_data, ['Alice', 'Bob', 'Charlie'])
decompressed_data = self.storage.get_column('name')
self.assertEqual(decompressed_data, ['Alice', 'Bob', 'Charlie'])
if __name__ == '__main__':
unittest.main()