Skip to content

Commit

Permalink
IGCFile: Expose WeGlide fields on the API
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Jan 17, 2021
1 parent 592dc33 commit bf3a7b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 13 additions & 1 deletion skylines/schemas/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class IGCFileSchema(Schema):

date = fields.Date(attribute="date_utc")

weglideStatus = fields.Integer(attribute="weglide_status")
weglideData = fields.Raw(attribute="weglide_data")

class Meta(Schema.Meta):
load_only = ("ownerId",)
dump_only = ("owner",)
Expand Down Expand Up @@ -230,7 +233,16 @@ class FlightSchema(Schema):
igcFile = fields.Nested(
IGCFileSchema,
attribute="igc_file",
only=("owner", "filename", "registration", "competitionId", "model", "date"),
only=(
"owner",
"filename",
"registration",
"competitionId",
"model",
"date",
"weglideStatus",
"weglideData",
),
)

class Meta(Schema.Meta):
Expand Down
6 changes: 6 additions & 0 deletions tests/api/views/flights/read_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def expected_basic_flight_json(flight):
u"competitionId": None,
u"model": None,
u"date": u"2011-06-18",
u"weglideStatus": None,
u"weglideData": None,
},
}

Expand Down Expand Up @@ -177,6 +179,8 @@ def test_filled_flight(db_session, client):
u"competitionId": u"TH",
u"model": u"Hornet",
u"date": u"2017-01-15",
u"weglideStatus": None,
u"weglideData": None,
},
}
}
Expand Down Expand Up @@ -269,6 +273,8 @@ def test_meetings(db_session, client):
},
u"model": None,
u"competitionId": None,
u"weglideStatus": None,
u"weglideData": None,
},
},
u"times": [
Expand Down
9 changes: 8 additions & 1 deletion tests/api/views/flights/upload_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def test_upload(db_session, client):
u"registration": u"LY-KDR",
u"competitionId": None,
u"filename": Match(r"simple(_\d+)?.igc"),
u"weglideStatus": None,
u"weglideData": None,
},
u"landingAirport": None,
u"triangleDistance": 4003,
Expand Down Expand Up @@ -299,7 +301,12 @@ def test_upload_with_weglide(db_session, client):
u"copilot": None,
u"copilotName": None,
u"distance": 7872,
u"igcFile": dict,
u"igcFile": Partial(
{
u"weglideStatus": 1,
u"weglideData": None,
}
),
u"pilotName": None,
u"pilot": {
u"id": john.id,
Expand Down

0 comments on commit bf3a7b0

Please sign in to comment.