Skip to content
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

🐛[#449] support objecttypes API with pagination #454

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

Coperh
Copy link
Contributor

@Coperh Coperh commented Sep 24, 2024

Fixes #449

Supports paginated response from OT V2

Comment on lines +60 to +67
v2_service = ServiceFactory(
api_root=self.object_types_api.format(version="v2"),
auth_type=AuthTypes.api_key,
header_key="Authorization",
header_value="Token 5cebbb33ffa725b6ed5e9e98300061218ba98d71",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should a docker container be made for objecttypes for testing here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so. We should be able to change and modify these tests.
If you decide to use vcr let's make sure we can reuse it:

  • please add docker-compose with Objecttypes
  • add fixture for Obejcttypes if you use it
  • add README which describes how to use it if you want to update cassettes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've split this into a separate issue #457

@Coperh
Copy link
Contributor Author

Coperh commented Sep 24, 2024

Idk why this is failing, I'll look into it later

edit: fixed

@Coperh Coperh force-pushed the feature/449-Permission-admin-500 branch from bca880e to c465f53 Compare September 25, 2024 07:42
Copy link
Collaborator

@annashamray annashamray left a comment

Choose a reason for hiding this comment

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

I like the idea to using vcr for Objecttypes API, but I think it needs a little more love

Comment on lines +60 to +67
v2_service = ServiceFactory(
api_root=self.object_types_api.format(version="v2"),
auth_type=AuthTypes.api_key,
header_key="Authorization",
header_value="Token 5cebbb33ffa725b6ed5e9e98300061218ba98d71",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so. We should be able to change and modify these tests.
If you decide to use vcr let's make sure we can reuse it:

  • please add docker-compose with Objecttypes
  • add fixture for Obejcttypes if you use it
  • add README which describes how to use it if you want to update cassettes

src/objects/token/tests/test_admin.py Outdated Show resolved Hide resolved
src/objects/token/tests/test_admin.py Outdated Show resolved Hide resolved
@Coperh Coperh force-pushed the feature/449-Permission-admin-500 branch 2 times, most recently from 3e1098e to 6baedab Compare September 27, 2024 09:27
@@ -52,6 +52,10 @@ def get_data_field_choices(self):
except requests.JSONDecodeError:
continue

# TODO: remove check once API V1 is removed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check will be pointless once Objectstypes API V1 is discontinued

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.31%. Comparing base (a5a0a50) to head (6baedab).
Report is 59 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
+ Coverage   95.18%   95.31%   +0.13%     
==========================================
  Files         150      155       +5     
  Lines        5105     5485     +380     
==========================================
+ Hits         4859     5228     +369     
- Misses        246      257      +11     
Flag Coverage Δ
95.31% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +78 to +88
form = response.context["adminform"].form
choices = list(form.fields["object_type"].choices)

self.assertEqual(
choices[1][0].value,
object_type.id,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like there was an easier way to check this with normal Django but maybe I'm thinking of webtest.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm yeah I think that's probably webtest

Comment on lines +78 to +88
form = response.context["adminform"].form
choices = list(form.fields["object_type"].choices)

self.assertEqual(
choices[1][0].value,
object_type.id,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm yeah I think that's probably webtest


self.assertEqual(
choices[1][0].value,
object_type.id,
Copy link
Contributor

Choose a reason for hiding this comment

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

bit of a nitpick, but is it possible to check the label here as well? Currently it will probably just check if the value is 1, which doesn't really say a lot 😬

@Coperh Coperh force-pushed the feature/449-Permission-admin-500 branch from 6baedab to 36f9c6f Compare September 27, 2024 09:47
@Coperh Coperh merged commit e9a69ef into master Sep 27, 2024
14 checks passed
@Coperh Coperh deleted the feature/449-Permission-admin-500 branch September 27, 2024 10:12
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.

Objects API: setting permissions causes a 500 error
4 participants