Django Unit Test Generator for Viewsets — ChatGPT prompt
Generate Django Viewset tests for CRUD requests, invalid input, and permission cases. Provide the class you want to cover.
Open on GitHubWhat Django Unit Test Generator for Viewsets does
Give the prompt a Django Viewset class. It will draft tests for creating, reading, updating, and deleting resources, then add cases for invalid input and permission problems.
The generated tests use Django’s TestCase and APIClient, with setup methods for any data the requests need. Descriptive test method names and comments are part of the requested output. Since the prompt asks for Django conventions, check that each proposed case matches the behavior of your Viewset.
What it helps with
- cover Viewset CRUD operations with tests
- check how invalid input is handled
- test requests with insufficient permissions
- set up data for API request tests
Example prompts for the agent
- Write tests for this Django Viewset, covering create, read, update, and delete requests.
- Add cases for invalid input and requests made without the required permissions.
- Use
TestCaseandAPIClient, and prepare the data needed by the tests.
How to install Django Unit Test Generator for Viewsets
How to use
Paste the text at the start of a chat or into project instructions
Manually: put the files in place
.claude/commands/prompts.csv.mdQuestions about Django Unit Test Generator for Viewsets
How do I install Django Unit Test Generator for Viewsets in ChatGPT?
Open a ChatGPT conversation and give the prompt the Django Viewset class you want to test.
What does Django Unit Test Generator for Viewsets do?
It drafts unit tests for Viewset CRUD operations and adds cases for invalid input and permission issues.
Which testing tools does the prompt use?
It asks for Django’s TestCase and APIClient, with setup methods to prepare required data.
Source text
prompts.csv · CC0-1.0
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.
© koksalkapucuoglu · CC0-1.0 · f/prompts.chat