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

Create RequestFactory to eventually replace create_test_request #497

Merged
merged 9 commits into from
Sep 22, 2022

Conversation

seladb
Copy link
Contributor

@seladb seladb commented Sep 20, 2022

Addresses issue #459

To make it easier to review, this PR only adds RequestFactory and doesn't remove create_test_request. Once this is merged I'll open another PR to replace and remove create_test_request

The RequestFactory is heavily inspired by Django's RequestFactory

PR Checklist

  • Have you followed the guidelines in CONTRIBUTING.md?
  • Have you got 100% test coverage on new code?
  • Have you updated the prose documentation?
  • Have you updated the reference documentation?

@seladb seladb marked this pull request as ready for review September 20, 2022 08:22
@Goldziher
Copy link
Contributor

This looks good!

Please add doc strings to all methods, even private ones, and add a doc string to the __init__ method which gives an explanation on the class etc. See for example the doc string in starlite.datastructures.State.__init__.

@seladb
Copy link
Contributor Author

seladb commented Sep 21, 2022

This looks good!

Please add doc strings to all methods, even private ones, and add a doc string to the __init__ method which gives an explanation on the class etc. See for example the doc string in starlite.datastructures.State.__init__.

Thanks @Goldziher , added here: f68b46a

@seladb
Copy link
Contributor Author

seladb commented Sep 21, 2022

@Goldziher is it safe to merge?

Copy link
Contributor

@peterschutt peterschutt left a comment

Choose a reason for hiding this comment

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

@seladb
Copy link
Contributor Author

seladb commented Sep 21, 2022

Should add docs: https://starlite-api.github.io/starlite/usage/14-testing/#creating-a-test-request and also add the class and public members to reference docs: https://github.com/starlite-api/starlite/blob/main/docs/reference/testing.md

@peterschutt I think I'll do it as part of the next PR which removes create_test_request otherwise it might be confusing to have 2 ways to create test request, what do you think? 🤔

starlite/testing.py Outdated Show resolved Hide resolved
@Goldziher
Copy link
Contributor

@Goldziher is it safe to merge?

merge when ready

@seladb
Copy link
Contributor Author

seladb commented Sep 22, 2022

Should add docs: https://starlite-api.github.io/starlite/usage/14-testing/#creating-a-test-request and also add the class and public members to reference docs: https://github.com/starlite-api/starlite/blob/main/docs/reference/testing.md

@peterschutt I think I'll do it as part of the next PR which removes create_test_request otherwise it might be confusing to have 2 ways to create test request, what do you think? 🤔

When thinking about it again, since create_test_request is exposed to users, can we actually remove it? If we do and someone uses it, it'd be a breaking change for them.
What do you think we should do?

  • Keep both create_test_request and the new RequestFactory and mark create_test_request as deprecated? (if so, what's the best way to mark something as deprecated?)
  • Or just remove create_test_request once this PR is merged?

This decision also affects the documentation we want to add about the new RequestFactory

cc @Goldziher @peterschutt @infohash

@peterschutt
Copy link
Contributor

When thinking about it again, since create_test_request is exposed to users, can we actually remove it? If we do and someone uses it, it'd be a breaking change for them.
What do you think we should do?

It should be deprecated if we are to remove it. Can you re-implement it so that keeps the same interface but uses RequestFactory underneath?

@seladb
Copy link
Contributor Author

seladb commented Sep 22, 2022

When thinking about it again, since create_test_request is exposed to users, can we actually remove it? If we do and someone uses it, it'd be a breaking change for them.
What do you think we should do?

It should be deprecated if we are to remove it. Can you re-implement it so that keeps the same interface but uses RequestFactory underneath?

Yes sure, that's a good idea. So I'll update the documentation in this PR and mention create_test_request as deprecated. In a following PR I'll remove all of our internal usages of create_test_request and re-implement this method to use RequestFactory. @peterschutt does that work?

@peterschutt
Copy link
Contributor

Yes sure, that's a good idea. So I'll update the documentation in this PR and mention create_test_request as deprecated. In a following PR I'll remove all of our internal usages of create_test_request and re-implement this method to use RequestFactory. @peterschutt does that work?

Sounds reasonable to me. If it isn't hard to implement it using RequestFactory then I wouldn't even worry about the deprecation - saves people having to rewrite tests if we can keep the interface.

@seladb
Copy link
Contributor Author

seladb commented Sep 22, 2022

Yes sure, that's a good idea. So I'll update the documentation in this PR and mention create_test_request as deprecated. In a following PR I'll remove all of our internal usages of create_test_request and re-implement this method to use RequestFactory. @peterschutt does that work?

Sounds reasonable to me. If it isn't hard to implement it using RequestFactory then I wouldn't even worry about the deprecation - saves people having to rewrite tests if we can keep the interface.

ok sure, I'll do it in a separate PR

@seladb seladb merged commit 498372b into litestar-org:main Sep 22, 2022
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.

None yet

4 participants