Skip to content

Problema ao testar uma função do repository usando o paginate #1088

Answered by uriyyo
anaplopes asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @anaplopes,

Sorry, I don't speak Portuguese, I used google translate to understand your problem. Please, correct me if I'm wrong and didn't understand some parts correctly.

So you have an issue because resolve_params raises an exception in your tests and you propose to add some default value that can be used for cases when no paras is set. Am I correct?

You can try to use function set_params function for such cases. It will do exactly what you want to achieve.
So inside your tests instead of mocking resolve_params function you can just call set_params with default params values that you want to use:

from fastapi_pagination import set_params

set_params(Params(page=1, size=50))

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@anaplopes
Comment options

@uriyyo
Comment options

Answer selected by anaplopes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants