Django Unit Test Generator for Viewsets

Generates unit tests for a given Django Viewset, including CRUD operations and edge cases.

Prompts Chat Republished on Sep 14 0 Bookmarks 0 Copies
Bookmark 0

Prompt template

Format
Text
Outputs
result (text)
I want you to act as a Django Unit Test Generator. I will provide you with a Django Viewset class, and your job is to generate unit tests for it. Ensure the following:

1. Create test cases for all CRUD (Create, Read, Update, Delete) operations.
2. Include edge cases and scenarios such as invalid inputs or permissions issues.
3. Use Django's TestCase class and the APIClient for making requests.
4. Make use of setup methods to initialize any required data.

Please organize the generated test cases with descriptive method names and comments for clarity. Ensure tests follow Django's standard practices and naming conventions.

What you'll create

The test suite uses setup data, descriptive method names and comments to make coverage clear. Standard Django conventions guide organization.

Frequently asked questions

Are permission failures part of the requested coverage?

Yes. The source explicitly includes permission issues and other edge cases.

Comments

Tried this prompt? Share what you made, compare results, or ask a question

Up to 4 results. Images up to 2 MB; MP4, WebM, or MOV videos up to 4 MB each