Skip to content

A good way to compare the expected queryset with the results of the response #9550

Discussion options

You must be logged in to vote

Make your test more focused, reducing its scope:

  • don't create 100s of objects in your test setup
  • try to ask yourself: what is this test testing? What do I really care about? If the answer contains one or more "and", it sometimes mean that you should split into multiple tests
  • if the response payload is actually large, perhaps your endpoint is returning too much at once and it may be an indication that it should be broken down

Personally, I like to create a single entry to test the retrieve part of my viewset, and check the full payload, status code, etc... But in case of list/filter endpoints, I would only check the ID / name attribute to make sure the ones I expect to see are present, n…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Antoliny0919
Comment options

@browniebroke
Comment options

Answer selected by Antoliny0919
@Antoliny0919
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants