示例#1
0
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",
            },
        ]
    }
示例#2
0
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',
        }],
    }
示例#3
0
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"},
        ]
    }
示例#4
0
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',
        }],
    }
示例#5
0
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',
        }],
    }
示例#6
0
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",
            },
        }
    }
示例#7
0
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',
            },
        }
    }
示例#8
0
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',
            },
        }
    }
示例#9
0
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',
        }],
    }
示例#10
0
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",
            },
        }
    }