|
@@ -26,12 +26,14 @@ class TestMongodbHandler(unittest.TestCase):
|
|
|
self.valid_input = {
|
|
|
"test_value_string": "test_value",
|
|
|
"test_value_double": 2.4,
|
|
|
- "test_value_double_array": [1.4, 1.6, 3.5]
|
|
|
+ "test_value_double_array": [1.4, 1.6, 3.5],
|
|
|
+ "test_value_date": "2020-01-28T15:45:25.000Z"
|
|
|
}
|
|
|
self.invalid_input = {
|
|
|
"test_value_string": 1,
|
|
|
"test_value_double": "Wrong value",
|
|
|
- "test_value_double_array": [1.4, 1.6, 3.5]
|
|
|
+ "test_value_double_array": [1.4, 1.6, 3.5],
|
|
|
+ "test_value_date": "2019-01-28T15:45:25.000Z"
|
|
|
}
|
|
|
|
|
|
|
|
@@ -82,6 +84,7 @@ class TestMongodbHandler(unittest.TestCase):
|
|
|
Fetch data and confirms thats it is the same as was entered into the database
|
|
|
Do the same with more specific query
|
|
|
'''
|
|
|
+
|
|
|
self.assertEqual(self.mongodb_handler.query_data_and_generate_dataframe(self.first_collection_name).to_dict()['test_value_double'][0], self.valid_input['test_value_double'])
|
|
|
self.assertEqual(self.mongodb_handler.query_data_and_generate_dataframe(self.first_collection_name, 'test_value_string', 'test_value').to_dict()['test_value_double'][0], self.valid_input['test_value_double'])
|
|
|
|
|
@@ -94,7 +97,7 @@ class TestMongodbHandler(unittest.TestCase):
|
|
|
{ '$match': {}}
|
|
|
]
|
|
|
self.assertEqual(self.mongodb_handler.aggregate_data_and_generate_dataframe(self.first_collection_name, aggregation_pipeline).to_dict()['test_value_double'][0], self.valid_input['test_value_double'])
|
|
|
-
|
|
|
+
|
|
|
def test_G_update_data_in_collection(self):
|
|
|
'''
|
|
|
Fetch data from database
|
|
@@ -117,6 +120,12 @@ class TestMongodbHandler(unittest.TestCase):
|
|
|
index = 'test_value_string'
|
|
|
self.mongodb_handler.create_index(self.first_collection_name, index)
|
|
|
self.assertTrue(index in list(self.database[self.first_collection_name].index_information().keys()))
|
|
|
+
|
|
|
+ def test_I_query_data_between_dates_and_generate_dataframe(self):
|
|
|
+
|
|
|
+ data = self.mongodb_handler.query_data_between_dates_and_generate_dataframe(self.first_collection_name, "test_value_date", "2020-01-27T15:45:25.000Z", "2020-01-29T15:45:25.000Z", index ='test_value_string')
|
|
|
+ print(data)
|
|
|
+ self.assertEqual(data['test_value_double'][0], self.valid_input['test_value_double'])
|
|
|
|
|
|
def test_Y_drop_collection(self):
|
|
|
'''
|