def test_existing_club(db_session, client, test_user): lva = clubs.lva() add_fixtures(db_session, lva) res = client.put("/clubs", headers=auth_for(test_user), json={"name": "LV Aachen"}) assert res.status_code == 422 assert res.json["error"] == "duplicate-club-name"
def test_search(db_session, client): edka = airports.merzbrueck() lva = clubs.lva() add_fixtures( db_session, users.john(), users.jane(), lva, clubs.sfn(), edka, airports.meiersberg(), ) res = client.get("/search?text=aachen") assert res.status_code == 200 assert res.json == { "results": [ { "id": edka.id, "type": "airport", "name": "Aachen Merzbruck", "icao": "EDKA", "frequency": "122.875", }, { "id": lva.id, "type": "club", "name": "LV Aachen", "website": "http://www.lv-aachen.de", }, ] }
def test_existing_club(db_session, client, test_user): lva = clubs.lva() add_fixtures(db_session, lva) res = client.put('/clubs', headers=auth_for(test_user), json={ 'name': 'LV Aachen', }) assert res.status_code == 422 assert res.json['error'] == 'duplicate-club-name'
def test_name_filter(db_session, client): add_fixtures(db_session, clubs.sfn(), clubs.lva()) res = client.get("/clubs?name=LV%20Aachen") assert res.status_code == 200 assert res.json == S( {"clubs": ExactSequence([{ "id": int, "name": "LV Aachen" }])})
def test_existing_club(db_session, client, test_user): lva = clubs.lva() sfn = clubs.sfn() test_user.club = sfn add_fixtures(db_session, lva) res = client.post('/clubs/{id}'.format(id=sfn.id), headers=auth_for(test_user), json={ 'name': 'LV Aachen', }) assert res.status_code == 422 assert res.json['error'] == 'duplicate-club-name'
def test_with_club_parameter(db_session, client): john = users.john(club=clubs.lva()) add_fixtures(db_session, john, users.jane(), users.max()) res = client.get("/users") assert res.status_code == 200 assert len(res.json["users"]) == 3 res = client.get("/users?club={club}".format(club=john.club.id)) assert res.status_code == 200 assert len(res.json["users"]) == 1 assert res.json == {u"users": [{u"id": john.id, u"name": u"John Doe"}]}
def test_pilot_changing_same_pilot_and_co(db_session, client): """ Pilot is trying to change copilot to the same as pilot. """ john = users.john(club=clubs.lva()) flight = flights.one(igc_file=igcs.simple(owner=john)) add_fixtures(db_session, flight, john) response = client.post('/flights/{id}'.format(id=flight.id), headers=auth_for(john), json={ 'pilotId': john.id, 'copilotId': john.id, }) assert response.status_code == 422
def test_name_filter(db_session, client): sfn = clubs.sfn() lva = clubs.lva() add_fixtures(db_session, sfn, lva) res = client.get('/clubs?name=LV%20Aachen') assert res.status_code == 200 assert res.json == { 'clubs': [{ 'id': lva.id, 'name': 'LV Aachen', }] }
def test_existing_club(db_session, client, test_user): lva = clubs.lva() sfn = clubs.sfn() test_user.club = sfn add_fixtures(db_session, lva) res = client.post( "/clubs/{id}".format(id=sfn.id), headers=auth_for(test_user), json={"name": "LV Aachen"}, ) assert res.status_code == 422 assert res.json["error"] == "duplicate-club-name"
def test_pilot_changing_pilot_and_co_null(db_session, client): """ Pilot is changing pilot and copilot to unknown user accounts. """ john = users.john(club=clubs.lva()) flight = flights.one(igc_file=igcs.simple(owner=john)) add_fixtures(db_session, flight, john) response = client.post('/flights/{id}'.format(id=flight.id), headers=auth_for(john), json={ 'pilotName': 'foo', 'copilotName': 'bar', }) assert response.status_code == 200
def test_pilot_changing_correct_with_co(db_session, client): """ Pilot is changing copilot to user from same club. """ john = users.john(club=clubs.lva()) jane = users.jane(club=john.club) flight = flights.one(igc_file=igcs.simple(owner=john)) add_fixtures(db_session, flight, john, jane) response = client.post('/flights/{id}'.format(id=flight.id), headers=auth_for(john), json={ 'pilotId': john.id, 'copilotId': jane.id, }) assert response.status_code == 200
def test_lva(db_session, client): lva = clubs.lva(owner=users.john()) add_fixtures(db_session, lva) res = client.get("/clubs/{id}".format(id=lva.id)) assert res.status_code == 200 assert res.json == { "id": lva.id, "name": "LV Aachen", "timeCreated": "2015-12-24T12:34:56+00:00", "website": "http://www.lv-aachen.de", "isWritable": False, "owner": {"id": lva.owner.id, "name": lva.owner.name}, }
def test_pilot_changing_disallowed_copilot(db_session, client): """ Pilot is trying to change copilot to user from different club. """ john = users.john(club=clubs.lva()) max = users.max(club=clubs.sfn()) flight = flights.one(igc_file=igcs.simple(owner=john)) add_fixtures(db_session, flight, john, max) response = client.post('/flights/{id}'.format(id=flight.id), headers=auth_for(john), json={ 'pilotId': john.id, 'copilotId': max.id, }) assert response.status_code == 422
def test_pilot_changing_clubless_co(db_session, client): """ Pilot is trying to change copilot to user without club. """ john = users.john(club=clubs.lva()) jane = users.jane() flight = flights.one(igc_file=igcs.simple(owner=john)) add_fixtures(db_session, flight, john, jane) response = client.post( "/flights/{id}".format(id=flight.id), headers=auth_for(john), json={"pilotId": john.id, "copilotId": jane.id}, ) assert response.status_code == 422
def test_with_club(db_session, client): john = users.john(club=clubs.lva()) add_fixtures(db_session, john) res = client.get("/users") assert res.status_code == 200 assert res.json == { u"users": [ { u"id": john.id, u"name": u"John Doe", u"club": {u"id": john.club.id, u"name": u"LV Aachen"}, } ] }
def test_pilot_changing_disowned_flight(db_session, client): """ Unrelated user is trying to change pilots. """ john = users.john(club=clubs.lva()) jane = users.jane(club=john.club) max = users.max(club=clubs.sfn()) flight = flights.one(igc_file=igcs.simple(owner=john)) add_fixtures(db_session, flight, john, jane, max) response = client.post('/flights/{id}'.format(id=flight.id), headers=auth_for(jane), json={ 'pilotId': john.id, 'copilotId': max.id, }) assert response.status_code == 403
def test_writable(db_session, client): lva = clubs.lva() john = users.john(club=lva) add_fixtures(db_session, lva, john) res = client.get('/clubs/{id}'.format(id=lva.id), headers=auth_for(john)) assert res.status_code == 200 assert res.json == { 'id': lva.id, 'name': 'LV Aachen', 'timeCreated': '2015-12-24T12:34:56+00:00', 'website': 'http://www.lv-aachen.de', 'isWritable': True, 'owner': None, }
def test_writable(db_session, client): lva = clubs.lva() john = users.john(club=lva) add_fixtures(db_session, lva, john) res = client.get("/clubs/{id}".format(id=lva.id), headers=auth_for(john)) assert res.status_code == 200 assert res.json == { "id": lva.id, "name": "LV Aachen", "timeCreated": "2015-12-24T12:34:56+00:00", "website": "http://www.lv-aachen.de", "isWritable": True, "owner": None, }
def test_with_club(db_session, client): john = users.john(club=clubs.lva()) add_fixtures(db_session, john) res = client.get('/users') assert res.status_code == 200 assert res.json == { u'users': [{ u'id': john.id, u'name': u'John Doe', u'club': { u'id': john.club.id, u'name': u'LV Aachen', }, }] }
def test_list_all(db_session, client): sfn = clubs.sfn() lva = clubs.lva() add_fixtures(db_session, sfn, lva) res = client.get('/clubs') assert res.status_code == 200 assert res.json == { 'clubs': [{ 'id': lva.id, 'name': 'LV Aachen', }, { 'id': sfn.id, 'name': 'Sportflug Niederberg', }] }
def test_with_club(db_session, client): john = users.john(club=clubs.lva()) add_fixtures(db_session, john) res = client.get("/users") assert res.status_code == 200 assert res.json == { u"users": [{ u"id": john.id, u"name": u"John Doe", u"club": { u"id": john.club.id, u"name": u"LV Aachen" }, }] }
def test_with_club_parameter(db_session, client): john = users.john(club=clubs.lva()) add_fixtures(db_session, john, users.jane(), users.max()) res = client.get('/users') assert res.status_code == 200 assert len(res.json['users']) == 3 res = client.get('/users?club={club}'.format(club=john.club.id)) assert res.status_code == 200 assert len(res.json['users']) == 1 assert res.json == { u'users': [{ u'id': john.id, u'name': u'John Doe', }] }
def test_lva(db_session, client): lva = clubs.lva(owner=users.john()) add_fixtures(db_session, lva) res = client.get('/clubs/{id}'.format(id=lva.id)) assert res.status_code == 200 assert res.json == { 'id': lva.id, 'name': 'LV Aachen', 'timeCreated': '2015-12-24T12:34:56+00:00', 'website': 'http://www.lv-aachen.de', 'isWritable': False, 'owner': { 'id': lva.owner.id, 'name': lva.owner.name, }, }
def test_pilot_changing_clubless_co(db_session, client): """ Pilot is trying to change copilot to user without club. """ john = users.john(club=clubs.lva()) jane = users.jane() flight = flights.one(igc_file=igcs.simple(owner=john)) add_fixtures(db_session, flight, john, jane) response = client.post( "/flights/{id}".format(id=flight.id), headers=auth_for(john), json={ "pilotId": john.id, "copilotId": jane.id }, ) assert response.status_code == 422
def test_list_all(db_session, client): add_fixtures(db_session, clubs.sfn(), clubs.lva()) res = client.get("/clubs") assert res.status_code == 200 assert res.json == S({ "clubs": ExactSequence([ { "id": int, "name": "LV Aachen" }, { "id": int, "name": "Sportflug Niederberg" }, ]) })
def test_search_doe(db_session, client): john = users.john() jane = users.jane() add_fixtures(db_session, john, jane, clubs.lva(), clubs.sfn(), airports.merzbrueck(), airports.meiersberg()) res = client.get('/search?text=doe') assert res.status_code == 200 assert res.json == { 'results': [{ 'id': jane.id, 'type': 'user', 'name': 'Jane Doe', }, { 'id': john.id, 'type': 'user', 'name': 'John Doe', }], }
def test_search_doe(db_session, client): john = users.john() jane = users.jane() add_fixtures( db_session, john, jane, clubs.lva(), clubs.sfn(), airports.merzbrueck(), airports.meiersberg(), ) res = client.get("/search?text=doe") assert res.status_code == 200 assert res.json == { "results": [ {"id": jane.id, "type": "user", "name": "Jane Doe"}, {"id": john.id, "type": "user", "name": "John Doe"}, ] }
def test_search(db_session, client): edka = airports.merzbrueck() lva = clubs.lva() add_fixtures(db_session, users.john(), users.jane(), lva, clubs.sfn(), edka, airports.meiersberg()) res = client.get('/search?text=aachen') assert res.status_code == 200 assert res.json == { 'results': [{ 'id': edka.id, 'type': 'airport', 'name': 'Aachen Merzbruck', 'icao': 'EDKA', 'frequency': '122.875', }, { 'id': lva.id, 'type': 'club', 'name': 'LV Aachen', 'website': 'http://www.lv-aachen.de', }], }
def test_filled_flight(db_session, client): lva = clubs.lva() john = users.john(club=lva) jane = users.jane() flight = flights.filled( pilot=john, pilot_name=u"johnny_d", co_pilot=jane, co_pilot_name=u"jane", club=lva, model=aircraft_models.nimeta(), takeoff_airport=airports.meiersberg(), landing_airport=airports.merzbrueck(), igc_file=igcs.filled(owner=john), ) add_fixtures(db_session, flight, traces.olc_classic(flight=flight)) res = client.get("/flights/{id}".format(id=flight.id)) assert res.status_code == 200 assert res.json == { u"flight": { u"id": flight.id, u"timeCreated": u"2016-12-30T11:23:45+00:00", u"pilot": { u"id": john.id, u"name": u"John Doe" }, u"pilotName": u"johnny_d", u"copilot": { u"id": jane.id, u"name": u"Jane Doe" }, u"copilotName": u"jane", u"club": { u"id": lva.id, u"name": u"LV Aachen" }, u"model": { u"id": flight.model_id, u"name": u"Nimeta", u"type": u"glider", u"index": 112, }, u"registration": u"D-1234", u"competitionId": u"701", u"scoreDate": u"2011-06-18", u"takeoffTime": u"2016-12-30T11:12:23+00:00", u"scoreStartTime": u"2016-12-30T11:17:23+00:00", u"scoreEndTime": u"2016-12-30T16:04:40+00:00", u"landingTime": u"2016-12-30T16:15:40+00:00", u"takeoffAirport": { u"id": flight.takeoff_airport.id, u"name": u"Meiersberg", u"countryCode": u"DE", }, u"landingAirport": { u"id": flight.landing_airport.id, u"name": u"Aachen Merzbruck", u"countryCode": u"DE", }, u"distance": 512, u"triangleDistance": 432, u"rawScore": 799.0, u"score": 713.3928571428571, u"speed": 30.84579717542964, u"privacyLevel": 0, u"igcFile": { u"owner": { u"id": john.id, u"name": u"John Doe" }, u"filename": u"abc1234d.igc", u"registration": u"D-4449", u"competitionId": u"TH", u"model": u"Hornet", u"date": u"2017-01-15", }, } }
def test_filled_flight(db_session, client): lva = clubs.lva() john = users.john(club=lva) jane = users.jane() flight = flights.filled( pilot=john, pilot_name=u"johnny_d", co_pilot=jane, co_pilot_name=u"jane", club=lva, model=aircraft_models.nimeta(), takeoff_airport=airports.meiersberg(), landing_airport=airports.merzbrueck(), igc_file=igcs.filled(owner=john), ) add_fixtures(db_session, flight, traces.olc_classic(flight=flight)) res = client.get("/flights/{id}".format(id=flight.id)) assert res.status_code == 200 assert res.json == { u"flight": { u"id": flight.id, u"timeCreated": u"2016-12-30T11:23:45+00:00", u"pilot": {u"id": john.id, u"name": u"John Doe"}, u"pilotName": u"johnny_d", u"copilot": {u"id": jane.id, u"name": u"Jane Doe"}, u"copilotName": u"jane", u"club": {u"id": lva.id, u"name": u"LV Aachen"}, u"model": { u"id": flight.model_id, u"name": u"Nimeta", u"type": u"glider", u"index": 112, }, u"registration": u"D-1234", u"competitionId": u"701", u"scoreDate": u"2011-06-18", u"takeoffTime": u"2016-12-30T11:12:23+00:00", u"scoreStartTime": u"2016-12-30T11:17:23+00:00", u"scoreEndTime": u"2016-12-30T16:04:40+00:00", u"landingTime": u"2016-12-30T16:15:40+00:00", u"takeoffAirport": { u"id": flight.takeoff_airport.id, u"name": u"Meiersberg", u"countryCode": u"DE", }, u"landingAirport": { u"id": flight.landing_airport.id, u"name": u"Aachen Merzbruck", u"countryCode": u"DE", }, u"distance": 512, u"triangleDistance": 432, u"rawScore": 799.0, u"score": 713.3928571428571, u"speed": 30.84579717542964, u"privacyLevel": 0, u"igcFile": { u"owner": {u"id": john.id, u"name": u"John Doe"}, u"filename": u"abc1234d.igc", u"registration": u"D-4449", u"competitionId": u"TH", u"model": u"Hornet", u"date": u"2017-01-15", }, } }
def test_event_types(db_session, client): john = users.john() jane = users.jane() flight = flights.one(igc_file=igcs.simple(owner=john)) flight_comment = flight_comments.emoji(flight=flight) flight_event = events.flight(actor=john, flight=flight) flight_comment_event = events.flight_comment(actor=john, flight=flight, flight_comment=flight_comment) follower_event = events.follower(actor=john, user=jane) new_user_event = events.new_user(actor=jane) club_join_event = events.club_join(actor=john, club=clubs.lva()) add_fixtures(db_session, flight_event, flight_comment_event, follower_event, new_user_event, club_join_event) res = client.get('/timeline') assert res.status_code == 200 assert res.json == { 'events': [{ 'id': club_join_event.id, 'type': 'club-join', 'time': '2017-02-15T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'club': { 'id': club_join_event.club.id, 'name': 'LV Aachen', }, }, { 'id': new_user_event.id, 'type': 'new-user', 'time': '2017-02-14T12:34:56', 'actor': { 'id': jane.id, 'name': 'Jane Doe', }, }, { 'id': follower_event.id, 'type': 'follower', 'time': '2017-02-13T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'user': { 'id': jane.id, 'name': 'Jane Doe', }, }, { 'id': flight_event.id, 'type': 'flight-upload', 'time': '2017-02-12T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'flight': { 'id': flight.id, 'date': '2011-06-18', 'pilot_id': john.id, 'copilot_id': None, 'distance': None, }, }, { 'id': flight_comment_event.id, 'type': 'flight-comment', 'time': '2017-02-11T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'flightComment': { 'id': flight_comment.id, }, 'flight': { 'id': flight.id, 'date': '2011-06-18', 'pilot_id': john.id, 'copilot_id': None, 'distance': None, }, }] }
def test_event_types(db_session, client): john = users.john() jane = users.jane() lva = clubs.lva() add_fixtures(db_session, john, jane, lva) flight = flights.one(igc_file=igcs.simple(owner=john)) flight_comment = flight_comments.emoji(flight=flight, user=john) add_fixtures(db_session, flight, flight_comment) flight_event = events.flight(flight) flight_comment_event = events.flight_comment(flight_comment) follower_event = events.follower(actor=john, user=jane) new_user_event = events.new_user(jane) club_join_event = events.club_join(actor=john, club=lva) add_fixtures(db_session, flight_event, flight_comment_event, follower_event, new_user_event, club_join_event) res = client.get('/timeline') assert res.status_code == 200 assert res.json == { 'events': [{ 'id': club_join_event.id, 'type': 'club-join', 'time': '2017-02-15T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'club': { 'id': club_join_event.club.id, 'name': 'LV Aachen', }, }, { 'id': new_user_event.id, 'type': 'new-user', 'time': '2017-02-14T12:34:56', 'actor': { 'id': jane.id, 'name': 'Jane Doe', }, }, { 'id': follower_event.id, 'type': 'follower', 'time': '2017-02-13T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'user': { 'id': jane.id, 'name': 'Jane Doe', }, }, { 'id': flight_event.id, 'type': 'flight-upload', 'time': '2017-02-12T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'flight': { 'id': flight.id, 'date': '2011-06-18', 'pilot_id': john.id, 'copilot_id': None, 'distance': None, }, }, { 'id': flight_comment_event.id, 'type': 'flight-comment', 'time': '2017-02-11T12:34:56', 'actor': { 'id': john.id, 'name': 'John Doe', }, 'flightComment': { 'id': flight_comment.id, }, 'flight': { 'id': flight.id, 'date': '2011-06-18', 'pilot_id': john.id, 'copilot_id': None, 'distance': None, }, }] }
def test_event_types(db_session, client): john = users.john() jane = users.jane() lva = clubs.lva() add_fixtures(db_session, john, jane, lva) flight = flights.one(igc_file=igcs.simple(owner=john)) flight_comment = flight_comments.emoji(flight=flight, user=john) add_fixtures(db_session, flight, flight_comment) flight_event = events.flight(flight) flight_comment_event = events.flight_comment(flight_comment) follower_event = events.follower(actor=john, user=jane) new_user_event = events.new_user(jane) club_join_event = events.club_join(actor=john, club=lva) add_fixtures( db_session, flight_event, flight_comment_event, follower_event, new_user_event, club_join_event, ) res = client.get("/timeline") assert res.status_code == 200 assert res.json == { "events": [ { "id": club_join_event.id, "type": "club-join", "time": "2017-02-15T12:34:56+00:00", "actor": { "id": john.id, "name": "John Doe" }, "club": { "id": club_join_event.club.id, "name": "LV Aachen" }, }, { "id": new_user_event.id, "type": "new-user", "time": "2017-02-14T12:34:56+00:00", "actor": { "id": jane.id, "name": "Jane Doe" }, }, { "id": follower_event.id, "type": "follower", "time": "2017-02-13T12:34:56+00:00", "actor": { "id": john.id, "name": "John Doe" }, "user": { "id": jane.id, "name": "Jane Doe" }, }, { "id": flight_event.id, "type": "flight-upload", "time": "2017-02-12T12:34:56+00:00", "actor": { "id": john.id, "name": "John Doe" }, "flight": { "id": flight.id, "date": "2011-06-18", "pilot_id": john.id, "copilot_id": None, "distance": None, }, }, { "id": flight_comment_event.id, "type": "flight-comment", "time": "2017-02-11T12:34:56+00:00", "actor": { "id": john.id, "name": "John Doe" }, "flightComment": { "id": flight_comment.id }, "flight": { "id": flight.id, "date": "2011-06-18", "pilot_id": john.id, "copilot_id": None, "distance": None, }, }, ] }
def test_filled_flight(db_session, client): lva = clubs.lva() john = users.john(club=lva) jane = users.jane() flight = flights.filled(pilot=john, pilot_name='johnny_d', co_pilot=jane, co_pilot_name='jane', club=lva, model=aircraft_models.nimeta(), takeoff_airport=airports.meiersberg(), landing_airport=airports.merzbrueck(), igc_file=igcs.filled(owner=john)) add_fixtures(db_session, flight, traces.olc_classic(flight=flight)) res = client.get('/flights/{id}'.format(id=flight.id)) assert res.status_code == 200 assert res.json == { u'flight': { u'id': flight.id, u'timeCreated': u'2016-12-30T11:23:45+00:00', u'pilot': { u'id': john.id, u'name': u'John Doe' }, u'pilotName': u'johnny_d', u'copilot': { u'id': jane.id, u'name': u'Jane Doe' }, u'copilotName': u'jane', u'club': { u'id': lva.id, u'name': u'LV Aachen', }, u'model': { u'id': flight.model_id, u'name': u'Nimeta', u'type': u'glider', u'index': 112, }, u'registration': u'D-1234', u'competitionId': u'701', u'scoreDate': u'2011-06-18', u'takeoffTime': u'2016-12-30T11:12:23+00:00', u'scoreStartTime': u'2016-12-30T11:17:23+00:00', u'scoreEndTime': u'2016-12-30T16:04:40+00:00', u'landingTime': u'2016-12-30T16:15:40+00:00', u'takeoffAirport': { u'id': flight.takeoff_airport.id, u'name': u'Meiersberg', u'countryCode': u'DE' }, u'landingAirport': { u'id': flight.landing_airport.id, u'name': u'Aachen Merzbruck', u'countryCode': u'DE', }, u'distance': 512, u'triangleDistance': 432, u'rawScore': 799.0, u'score': 713.0, u'speed': 30.84579717542964, u'privacyLevel': 0, u'igcFile': { u'owner': { u'id': john.id, u'name': u'John Doe' }, u'filename': u'abc1234d.igc', u'registration': u'D-4449', u'competitionId': u'TH', u'model': u'Hornet', u'date': u'2017-01-15', }, } }
def test_filled_flight(db_session, client): lva = clubs.lva() john = users.john(club=lva) jane = users.jane() flight = flights.filled( pilot=john, pilot_name=u'johnny_d', co_pilot=jane, co_pilot_name=u'jane', club=lva, model=aircraft_models.nimeta(), takeoff_airport=airports.meiersberg(), landing_airport=airports.merzbrueck(), igc_file=igcs.filled(owner=john) ) add_fixtures(db_session, flight, traces.olc_classic(flight=flight)) res = client.get('/flights/{id}'.format(id=flight.id)) assert res.status_code == 200 assert res.json == { u'flight': { u'id': flight.id, u'timeCreated': u'2016-12-30T11:23:45+00:00', u'pilot': { u'id': john.id, u'name': u'John Doe' }, u'pilotName': u'johnny_d', u'copilot': { u'id': jane.id, u'name': u'Jane Doe' }, u'copilotName': u'jane', u'club': { u'id': lva.id, u'name': u'LV Aachen', }, u'model': { u'id': flight.model_id, u'name': u'Nimeta', u'type': u'glider', u'index': 112, }, u'registration': u'D-1234', u'competitionId': u'701', u'scoreDate': u'2011-06-18', u'takeoffTime': u'2016-12-30T11:12:23+00:00', u'scoreStartTime': u'2016-12-30T11:17:23+00:00', u'scoreEndTime': u'2016-12-30T16:04:40+00:00', u'landingTime': u'2016-12-30T16:15:40+00:00', u'takeoffAirport': { u'id': flight.takeoff_airport.id, u'name': u'Meiersberg', u'countryCode': u'DE' }, u'landingAirport': { u'id': flight.landing_airport.id, u'name': u'Aachen Merzbruck', u'countryCode': u'DE', }, u'distance': 512, u'triangleDistance': 432, u'rawScore': 799.0, u'score': 713.0, u'speed': 30.84579717542964, u'privacyLevel': 0, u'igcFile': { u'owner': { u'id': john.id, u'name': u'John Doe' }, u'filename': u'abc1234d.igc', u'registration': u'D-4449', u'competitionId': u'TH', u'model': u'Hornet', u'date': u'2017-01-15', }, } }
def test_event_types(db_session, client): john = users.john() jane = users.jane() lva = clubs.lva() add_fixtures(db_session, john, jane, lva) flight = flights.one(igc_file=igcs.simple(owner=john)) flight_comment = flight_comments.emoji(flight=flight, user=john) add_fixtures(db_session, flight, flight_comment) flight_event = events.flight(flight) flight_comment_event = events.flight_comment(flight_comment) follower_event = events.follower(actor=john, user=jane) new_user_event = events.new_user(jane) club_join_event = events.club_join(actor=john, club=lva) add_fixtures( db_session, flight_event, flight_comment_event, follower_event, new_user_event, club_join_event, ) res = client.get("/timeline") assert res.status_code == 200 assert res.json == { "events": [ { "id": club_join_event.id, "type": "club-join", "time": "2017-02-15T12:34:56+00:00", "actor": {"id": john.id, "name": "John Doe"}, "club": {"id": club_join_event.club.id, "name": "LV Aachen"}, }, { "id": new_user_event.id, "type": "new-user", "time": "2017-02-14T12:34:56+00:00", "actor": {"id": jane.id, "name": "Jane Doe"}, }, { "id": follower_event.id, "type": "follower", "time": "2017-02-13T12:34:56+00:00", "actor": {"id": john.id, "name": "John Doe"}, "user": {"id": jane.id, "name": "Jane Doe"}, }, { "id": flight_event.id, "type": "flight-upload", "time": "2017-02-12T12:34:56+00:00", "actor": {"id": john.id, "name": "John Doe"}, "flight": { "id": flight.id, "date": "2011-06-18", "pilot_id": john.id, "copilot_id": None, "distance": None, }, }, { "id": flight_comment_event.id, "type": "flight-comment", "time": "2017-02-11T12:34:56+00:00", "actor": {"id": john.id, "name": "John Doe"}, "flightComment": {"id": flight_comment.id}, "flight": { "id": flight.id, "date": "2011-06-18", "pilot_id": john.id, "copilot_id": None, "distance": None, }, }, ] }