def setUp(self): main.app.testing = True self.app = main.app.test_client() self.userIds = ["testuid1", "testuid2"] self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) for userId in self.userIds: form = FormDictFactory().create(returnDict=True) form["flightLocalTime"] = "2018-12-20T12:00:00.000" form["testUserId"] = userId r = self.app.post( # TODO: change everywhere to json=form (used to be json=json.dumps(form)) path='/rideRequests', json=form, headers=getMockAuthHeaders(userId)) print(r.json) # self.assertRaises(service_errors.RequestAlreadyExistsError) firestore_ref = r.json[ "firestoreRef"] # Not that it is actually rideRequestId self.ride_request_ids_to_unmatch.append((userId, firestore_ref)) self.ride_request_ids_to_delete.append((userId, firestore_ref)) uid, rid = self.ride_request_ids_to_delete[0] self.rideRequestId = rid r = self.app.post(path='/devForceMatch', json=json.dumps({ "operationMode": "two", "rideRequestIds": [i[1] for i in self.ride_request_ids_to_delete] }))
def setUp(self): self.refs_to_delete = list() event_dict = getEventDict(use_firestore_ref=True, to_earliest=1545033600, to_latest=1545119999, from_earliest=1545033600, from_latest=1545119999) self.event = Event.from_dict(event_dict) main.app.testing = True self.app = main.app.test_client() self.userId = "testuid1" self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) # Populate location location_ref = event_dict["locationRef"] location_d = getLocationDict(location_category="social") location = Location.from_dict(location_d) LocationGenericDao().set(location, location_ref) self.refs_to_delete.append(location_ref) event_ref: firestore.DocumentReference = EventDao().create(self.event) self.event.set_firestore_ref(event_ref) self.refs_to_delete.append(event_ref) self.event_id = event_ref.id
def setUp(self): self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) self.r = scripts.generate_ride_request() self.o = scripts.generate_orbit(self.r.event_ref)
def test_database_operations(self): c = setup_scripts.SetUpTestDatabase() c.clear_before() # Clear locations and events collection self.assertEqual(_count_location_docs(), 0, "locations collection should be cleared") self.assertEqual(_count_event_docs(), 0, "events collection should be cleared") c.generate_test_data( ) # Generate locations and events needed by a test case self.assertNotEqual(_count_location_docs(), 0, "locations collection should have documents") self.assertNotEqual(_count_event_docs(), 0, "events collection should have documents") c.clear_after() # Clear locations and events after the test case self.assertEqual(_count_location_docs(), 0, "locations collection should be cleared") self.assertEqual(_count_event_docs(), 0, "events collection should be cleared")
def setUp(self): main.app.testing = True self.app = main.app.test_client() self.userIds = ["testuid1", "testuid2"] self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5)
def test_database_operations(self): """ Note that tearDown is not called for this test. This test may crush all other tests. :return: """ c = setup_scripts.SetUpTestDatabase() c.clear_before() # Clear locations and events collection self.assertEqual(_count_location_docs(), 0, "locations collection should be cleared") self.assertEqual(_count_event_docs(), 0, "events collection should be cleared") c.generate_test_data( ) # Generate locations and events needed by a test case self.assertNotEqual(_count_location_docs(), 0, "locations collection should have documents") self.assertNotEqual(_count_event_docs(), 0, "events collection should have documents") c.clear_after() # Clear locations and events after the test case self.assertEqual(_count_location_docs(), 0, "locations collection should be cleared") self.assertEqual(_count_event_docs(), 0, "events collection should be cleared")
def setUp(self): # self.user = User.from_dict(userDict) self.to_delete = list() self.cl = setup_scripts.SetUpTestDatabase() self.cl.clear_before() self.pl = setup_scripts.scripts.populate_locations.PopulateLocationCommand() self.to_delete.extend(self.pl.execute())
def setUp(self): self.maxDiff = None self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) self.arr = [ [ 12000000, 12005000, RideRequestGenericDao().rideRequestCollectionRef.document('A') ], [ 12000000, 12005000, RideRequestGenericDao().rideRequestCollectionRef.document('B') ], [ 12000000, 12005000, RideRequestGenericDao().rideRequestCollectionRef.document('C') ], [ 12005000, 12006000, RideRequestGenericDao().rideRequestCollectionRef.document('D') ], [ 12007000, 12009000, RideRequestGenericDao().rideRequestCollectionRef.document('E') ], [ 12009001, 12009900, RideRequestGenericDao().rideRequestCollectionRef.document('F') ], [ 11000000, 11009000, RideRequestGenericDao().rideRequestCollectionRef.document('G') ] ] arr = self.arr rideRequests = list() for earliest, latest, firestoreRef in arr: rideRequest = test.store.model.getMockRideRequest( earliest=earliest, latest=latest, firestoreRef=firestoreRef, userId='userIdA' if firestoreRef.id == 'A' else 'userIdBmore') rideRequest.set_firestore_ref(firestoreRef) RideRequestGenericDao().set(rideRequest) rideRequests.append(rideRequest) self.rideRequests = rideRequests
def setUp(self): main.app.testing = True self.app = main.app.test_client() self.userIds = ["testuid1", "testuid2"] self.rideRequestIds = list() self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) _create_ride_requests_for_tests(self.app, self.userIds, self.ride_request_ids_to_delete, self.rideRequestIds)
def setUp(self): eventDict = getEventDict() self.event = Event.from_dict(eventDict) self.refs_to_delete = list() self.cl = setup_scripts.SetUpTestDatabase() self.cl.clear_before() self.pl = setup_scripts.scripts.populate_locations.PopulateLocationCommand( ) self.refs_to_delete.extend(self.pl.execute()) self.fb_event = Event.from_dict(getEventDict(event_category="social"))
def setUp(self): main.app.testing = True self.app = main.app.test_client() self.userId = "testuid1" self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) rideRequestIds = list() _create_ride_requests_for_tests(self.app, [self.userId], list(), rideRequestIds) self.rideRequestId = rideRequestIds.pop()
def setUp(self): self.maxDiff = None self.ride_request_ids_to_delete = list() main.app.testing = True self.app = main.app.test_client() self.userId = "testuid1" self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) rideRequestIds = list() _create_ride_requests_for_tests(self.app, [self.userId], list(), rideRequestIds) self.rideRequestId = rideRequestIds[0] self.ride_request_ids_to_delete.append( (self.userId, rideRequestIds[0]) )
def setUp(self): main.app.testing = True self.app = main.app.test_client() self.userIds = ["testuid1", "testuid2"] self.rideRequestIds = list() self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5) _create_ride_requests_for_tests(self.app, self.userIds, self.ride_request_ids_to_delete, self.rideRequestIds) r = self.app.post(path='/devForceMatch', json=json.dumps({ "rideRequestIds": self.rideRequestIds, "operationMode": "two" })) print(r.data) self.assertEqual(r.status_code, 200)
def setUp(self): self.c = scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data(start_string="2018-12-17T08:00:00.000", num_days=5)
def setUp(self): self.c = setup_scripts.SetUpTestDatabase() self.c.clear_before() self.c.generate_test_data()