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

Add tests to UserDeleteView endpoint #935

Conversation

Oksamies
Copy link
Contributor

@Oksamies Oksamies commented Dec 8, 2023

No description provided.

@Oksamies Oksamies mentioned this pull request Dec 8, 2023
Copy link
Contributor Author

Oksamies commented Dec 8, 2023

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Oksamies and the rest of your teammates on Graphite Graphite

@Oksamies Oksamies requested a review from MythicManiac December 8, 2023 18:32
Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (add-delete-user-endpoint@67fb284). Click here to learn what that means.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             add-delete-user-endpoint     #935   +/-   ##
===========================================================
  Coverage                            ?   92.69%           
===========================================================
  Files                               ?      279           
  Lines                               ?     8301           
  Branches                            ?      777           
===========================================================
  Hits                                ?     7695           
  Misses                              ?      500           
  Partials                            ?      106           

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

Copy link
Collaborator

@anttimaki anttimaki left a comment

Choose a reason for hiding this comment

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

Since I've not seen the code for the endpoint being tested here, I took this as a game, trying to guess how it's implemented and base my comments on that. Therefore the comments should be taken with a bit of salt.

):
api_client.force_authenticate(user)
response = api_client.post(
f"/api/cyberstorm/user/{user.username}/delete/",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we use DELETE http method instead of POSTing to URL with delete/ at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would probably be correct, but I'm not sure. I have a slight little memory that I would have asked this from @MythicManiac and that POSTing would have been the desired way. But can't say for sure.

user2 = UserFactory()
api_client.force_authenticate(user2)
response = api_client.post(
f"/api/cyberstorm/user/{user.username}/delete/",
Copy link
Collaborator

Choose a reason for hiding this comment

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

If user can only delete their own account, do we need to include the username in the URL? We could read it from the session, since we have to check it matches anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do that. But I opted to having the name be in the url as an extra precaution. In addition this way the view can be expanded to handle something like "admins can delete accounts" if the need arises.

@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from fc5cd99 to 0d6682c Compare December 11, 2023 15:33
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from 978adaa to 54a7930 Compare December 11, 2023 15:33
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 0d6682c to eac5259 Compare December 11, 2023 17:12
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from 54a7930 to bc3fe4e Compare December 11, 2023 17:12
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from eac5259 to 8c513d0 Compare December 11, 2023 17:39
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from bc3fe4e to 557c154 Compare December 11, 2023 17:39
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 8c513d0 to 4f2cfa1 Compare December 12, 2023 09:58
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from 557c154 to 20c4f17 Compare December 12, 2023 09:58
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 4f2cfa1 to 73f4b22 Compare December 12, 2023 09:59
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from 20c4f17 to 7a5ea26 Compare December 12, 2023 09:59
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 73f4b22 to 6d7cb43 Compare December 12, 2023 10:08
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from 7a5ea26 to 1cf2069 Compare December 12, 2023 10:08
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 6d7cb43 to de09dfd Compare December 13, 2023 12:12
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch 2 times, most recently from 981461a to a983b4b Compare December 13, 2023 12:15
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from de09dfd to 0eab37c Compare December 13, 2023 12:27
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from a983b4b to 4e5ac17 Compare December 13, 2023 12:27
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 0eab37c to 7c4a8e5 Compare December 13, 2023 12:40
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from 4e5ac17 to adc8b88 Compare December 13, 2023 12:41
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 7c4a8e5 to 67fb284 Compare December 13, 2023 16:13
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from adc8b88 to 7582784 Compare December 13, 2023 16:13
@Oksamies Oksamies force-pushed the 12-08-Add_tests_to_UserDeleteView_endpoint branch from 7582784 to 8357e34 Compare December 13, 2023 16:26
@Oksamies Oksamies force-pushed the add-delete-user-endpoint branch from 67fb284 to e27c47d Compare January 7, 2024 20:06
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.

2 participants