developer coding user risk: low
Django Viewset Unit Test Generator
Acts as a Django Unit Test Generator that takes a Django Viewset class and produces unit tests for all CRUD operations, edge cases like invalid inputs and permissions issues, using…
PROMPT
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.
REQUIRED CONTEXT
- Django Viewset class
ROLES & RULES
Role assignments
- act as a Django Unit Test Generator.
- Create test cases for all CRUD (Create, Read, Update, Delete) operations.
- Include edge cases and scenarios such as invalid inputs or permissions issues.
- Use Django's TestCase class and the APIClient for making requests.
- Make use of setup methods to initialize any required data.
- Organize the generated test cases with descriptive method names and comments for clarity.
- Ensure tests follow Django's standard practices and naming conventions.
EXPECTED OUTPUT
- Format
- code
- Constraints
-
- descriptive method names
- comments for clarity
- Django standard practices and naming conventions
SUCCESS CRITERIA
- Create test cases for all CRUD operations.
- Include edge cases such as invalid inputs or permissions issues.
- Use Django's TestCase and APIClient.
- Utilize setup methods for data initialization.
- Organize tests with descriptive names and comments.
- Follow Django testing standards.
FAILURE MODES
- May omit certain CRUD operations.
- Might skip edge cases like invalid inputs or permissions.
- Could neglect proper use of TestCase or APIClient.
- May not initialize required data in setup methods.
- Possibly ignore Django naming conventions.
CAVEATS
- Dependencies
-
- Django Viewset class provided by user.
- Missing context
-
- The code of the Django Viewset class to generate tests for
QUALITY
- OVERALL
- 0.90
- CLARITY
- 0.90
- SPECIFICITY
- 0.90
- REUSABILITY
- 0.95
- COMPLETENESS
- 0.85
IMPROVEMENT SUGGESTIONS
- Explicitly require a full, self-contained test class with all necessary imports and class definition.
- Add guidance on testing custom actions if present in the Viewset beyond standard CRUD.
- Specify handling of authentication/permissions, e.g., using force_authenticate().
USAGE
Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.
MORE FOR DEVELOPER
- Context7 Library Documentation Expert developer coding
- Structured Python Production Code Generator developer coding
- Angular Standalone Directive Generator developer coding
- Pytest Unit Test Suite Generator developer coding
- Unity Architecture Specialist developer coding
- Web Typography CSS Generator developer coding
- VSCode CodeTour File Expert developer coding
- Senior Python Code Reviewer developer coding
- Structured Cross-Language Code Translator developer coding
- Multi-DB SQL Query Optimizer and Builder developer coding
- Base R Programming Reference Guide developer coding
- Flutter Map SDK Layer Bug Fixer developer coding
- Expert Mobile App Builder for iOS Android developer coding
- Scalable Backend Architect Expert developer coding
- Comprehensive TypeScript Codebase Reviewer developer coding
- Code Improvement and Refactoring Suggester developer coding
- Vercel SPA Blank Screen Diagnoser developer coding
- CLAUDE.md File Generator for AI Coders developer coding
- App Store Screenshots Gallery Generator developer coding
- Spring Boot SOLID Architect Specialist developer coding
- React SaaS Metrics Dashboard Generator developer coding
- Software Optimization Auditor developer coding
- Senior Frontend Task Checklist Architect developer coding
- POSIX Shell Script Developer with Checklists developer coding
- Astro v6 Strict Architecture Rules developer coding