-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataStoreTest.py
More file actions
28 lines (23 loc) · 1.13 KB
/
dataStoreTest.py
File metadata and controls
28 lines (23 loc) · 1.13 KB
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
import unittest
from dataStore import DataStore
import start
__author__ = 'alexander'
class DataStoreTest(unittest.TestCase):
def setUp(self):
self.app = start.harApp
start.harApp.config['TESTING'] = True
start.harApp.config['DATABASE'] = 'test.db'
def testGetRawSamples(self):
with start.harApp.test_request_context(""):
# Test request contexts don't automatically call before_request. Set up DB manually.
start.set_app_db()
dataStore = DataStore()
sample_sets = dataStore.randomRawSamples(5, 500, 2)
self.assertEqual(len(sample_sets), 2, "Number of sets retrieved was not as expected")
for sample_set in sample_sets:
self.assertEqual(len(sample_set), 500, "Sample set size was not as expected")
def testListOfDictInversion(self):
data = [ {'id': 1, 'name' : 'alice'}, {'id': 2, 'name': 'bob'}, {'id': 4, 'name': 'charlie'}]
store = DataStore()
result = store._DataStore__listOfDictToDictOfList(data)
self.assertEqual(len(result['id']), 3, "Incorrect number of elements in column")