def test_gathering_publicity_remains_unchanged_after_unite(self): document.delete_all() _create_points_from_ecotone(self, "/Ecotones_gps_pos_gathering_duplicate_test.csv", "01-01-1000, 00-00-00") documents = document.find()[0] documents.gatherings[0].publicityRestrictions = "MZ.publicityRestrictionsPublic" documents.update() _create_points_from_ecotone(self, "/Ecotones_gps_pos_gathering_duplicate_test.csv", "24-11-2015, 00-00-00") self.assertEquals(document.find()[0].gatherings[0].publicityRestrictions, "MZ.publicityRestrictionsPublic")
def test_altitude_not_in_gathering_if_not_in_file(self): document.delete_all() _create_points_from_ecotone(self, "/Ecotones_gps_pos_doc_create_test2.csv") documents = document.find() result = len(documents[0].gatherings[0].geometry) == 2 self.assertEquals(result, True)
def getGatheringsForDevice(request): """ Django REST-interface controller for getting device-specific (devId request parameter) documents. """ docs = document.find(deviceID=request.GET.get('devId')) doc = docs[0].gatherings if len(docs) > 0 else [] gatherings = [g.to_lajistore_json() for g in doc] for g in gatherings: _move_altitude(g) return Response(gatherings)
def test_byholm_data_goes_to_lajiStore_succesfully(self): document.delete_all() path = settings.OTHER_ROOT + "/byholm_test.txt" file = open(path, "rb") entries = prepare_file(file, self.byholm_parser, "1010") create_points(entries, self.byholm_parser, "byholm_test.txt", datetime.datetime.now().strftime("%d-%m-%Y, %H:%M:%S")) documents = document.find() self.assertEqual(len(documents), 1) self.assertEqual(len(documents[0].gatherings), 5)
def _update_gatherings_to_lajiStore(collections): points = [] for k in collections.keys(): doc_array = document.find(deviceID=k) points += collections[k] if len(doc_array) == 0: document.create(collections[k], k) else: doc_array[0].gatherings = _union_of_gatherings(doc_array[0].gatherings, collections[k]) _check_redundant_lajiStore_documents(doc_array) doc_array[0].update() return points
def test_altitude_in_gathering(self): document.delete_all() _create_points_from_ecotone(self, "/Ecotones_gps_pos_doc_create_test.csv") for attempt in range(3): documents = document.find() result = documents[0].gatherings[0].geometry[2] == 1 if result: break time.sleep(4) self.assertEquals(result, True)
def test_merge_and_delete_if_three_documents_found_for_same_device(self): document.delete_all() device.delete_all() _create_points_from_ecotone(self, "/Ecotones_gps_pos_test.csv") dev = device.find()[0] gatherings = [gathering.Gathering("2015-09-15T08:00:00+03:00", [68.93023632, 23.19298104])] dict = { "deviceID": dev.id, "dateCreated": "2015-09-14T15:29:28+03:00", "dateEdited": "2015-09-14T15:29:28+03:00", "gatherings": gatherings } document.create(**dict) document.create(**dict) document.create(**dict) time.sleep(2) self.assertEqual(len(document.find()), 4) _create_points_from_ecotone(self, "/Ecotones_gps_pos_test.csv") time.sleep(2) self.assertEqual(len(document.find()),1)
def test_document_does_not_contain_duplicate_gathering(self): _create_points_from_ecotone(self, "/Ecotones_gps_pos_gathering_duplicate_test.csv") _create_points_from_ecotone(self, "/Ecotones_gps_pos_gathering_duplicate_test2.csv") documents = document.find() self.assertEqual(len(documents[0].gatherings), 1)
def test_create_points_method_correctly_updates_existing_documents(self): _create_points_from_ecotone(self, "/Ecotones_gps_pos_doc_create_test.csv") _create_points_from_ecotone(self, "/Ecotones_gps_pos_doc_create_test2.csv") time.sleep(2) self.assertEqual(len(document.find()),3)