def create_points(data): """ Creates a new entry for every Gathering not already in the database. :param data: The contents of the uploaded file. :return: A list containing all of the Gatherings found in the file. :return: A list containing all of the Gatherings found in the file. """ collections = {} for point in data: if point['GpsNumber'] not in collections: collections[point['GpsNumber']] = [] device.get_or_create(deviceId = point['GpsNumber'], parserInfo=parserInfo) collections[point['GpsNumber']].append( gathering.Gathering( time=ecotones_parse_time(point['GPSTime']), geometry = [float(point["Latitude"]), float(point["Longtitude"])], temperature=float(point['Temperature']) )) points = [] for k in collections.keys(): points += collections[k] document.create(str(uuid.uuid4()), collections[k], k) return points
def test_get_or_create(self): before = len(device.get_all()) device.get_or_create("ABCD1234567", {"type":"Type", "manufacturer":"Manu"}) self.assertEquals(before, len(device.get_all())) d = device.get_or_create("TESTTEST", {"type":"Type", "manufacturer":"Manu"}) self.assertLess(before, len(device.get_all())) d.delete()