Skip to content

[Issue 125 Fix] : Added Serializer Field to Properly Resolve Choices in Resource.media_type Field #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 3, 2020

Conversation

BethanyG
Copy link
Member

@BethanyG BethanyG commented May 2, 2020

Should fix #125.

  • Added class MediaTypeSerializerField(serializers.ChoiceField) with a to_representation and a to_internal_value to properly resolve the choices on the Resource.media_type field for Resources. in resources/serializers.py

  • Corrected and un-commented the create_one_resource_with_media_type test case and added a new create_one_resource_without_media_type test case for coverage. in resources/tests.py

BethanyG added 2 commits May 2, 2020 14:57
…on to fetch proper display name and added a serializer.ChoiceField to handle the choices option.
…d create_one_resource_without_media_type test.
@BethanyG BethanyG requested a review from a team May 2, 2020 22:05
@BethanyG BethanyG added this to the resources milestone May 2, 2020
@BethanyG BethanyG changed the title Issue 125: Added Serializer Field to Properly Resolve Choices in Resource.media_type Field Issue 125 Fix: Added Serializer Field to Properly Resolve Choices in Resource.media_type Field May 2, 2020
@BethanyG BethanyG changed the title Issue 125 Fix: Added Serializer Field to Properly Resolve Choices in Resource.media_type Field [Issue 125 Fix] : Added Serializer Field to Properly Resolve Choices in Resource.media_type Field May 2, 2020
@codecov
Copy link

codecov bot commented May 2, 2020

Codecov Report

Merging #140 into master will increase coverage by 1.43%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #140      +/-   ##
==========================================
+ Coverage   81.44%   82.88%   +1.43%     
==========================================
  Files          29       29              
  Lines         469      479      +10     
==========================================
+ Hits          382      397      +15     
+ Misses         87       82       -5     
Impacted Files Coverage Δ
project/resources/serializers.py 100.00% <100.00%> (ø)
project/resources/models.py 93.33% <0.00%> (+3.33%) ⬆️
project/resources/views.py 72.72% <0.00%> (+4.54%) ⬆️
project/tagging/serializers.py 91.66% <0.00%> (+8.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d289ecd...5d99fa0. Read the comment docs.

Copy link
Member

@lpatmo lpatmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks so much for fixing that media_type error! :D Confirmed that when I create a new resource with a blank field for media_type, it passes; if I create a resource with an invalid field, I get an error; if I create a new resource without a media_type field, I get an expected error.

Left one question about the key error returned if I pass in invalid media type... the tests pass, but I didn't see an expected list when I tried it out on Postman (see other comment).

@@ -1,4 +1,5 @@
from unittest import skip
from pytest import raises
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, didn't know about pytest.raises 👍

@BethanyG BethanyG merged commit 30a387c into codebuddies:master May 3, 2020
@BethanyG BethanyG deleted the issue-125 branch May 3, 2020 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Resources] Media Type Choices Field Value is Dropped when POSTing in JSON
2 participants