PromptBase
Close icon
General
Home
Marketplace
Hire
Create
Login
Sell
Explore
🤖 GPT

Unit Test Generator

Unit Test Generator gpt prompt mini thumbnail
2Heart icon
Favorites
125Eye icon
Views
TestedTick icon
TipsTick icon
Input the programming language you are using and the code snippet for which you want the unit tests generated and this prompt will generate the unit tests for you.
...more
$2.99
Get prompt
After purchasing, you will gain access to the prompt file which you can use with GPT or the app builder. You'll receive 20 free generation credits with this purchase. By purchasing this prompt, you agree to our terms of service.
Over 1 month ago

Prompt Details

Model
Chat - GPT-4 (gpt-4)
Token size
96 ($0.00290 / call)
Example input
[Programming Languge]: Python [Code]: Your code snippet
Example output
from rest_framework import status from rest_framework.test import APITestCase from django.urls import reverse from yourapp.models import Product, ProductVariation, LetteringItemCategory, LetteringItemVariation, ProductColor from yourapp.serializers import OrderSerializer from yourapp.views import CreateOrder class CreateOrderTests(APITestCase): def setUp(self): # Create sample data for testing self.product = Product.objects.create(id=1) self.product_color = ProductColor.objects.create(id=1) self.lettering_item_category = LetteringItemCategory.objects.create(id=1, title='Test') def create_order_request(self, product_color_id=None, lettering_items=None): data = { 'lettering_items': lettering_items if lettering_items is not None else [], 'product_color_id': product_color_id if product_color_id is not None else 1, 'order': { # order data fields } } return self.client.post(reverse('create_order', args=[self.product.id]), data, format='json') def test_create_order_success(self): response = self.create_order_request( product_color_id=self.product_color.id, lettering_items=[ {'title': 'Test', 'text': 'item1'}, {'title': 'Test', 'text': 'item2'} ] ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(ProductVariation.objects.count(), 1) self.assertEqual(LetteringItemVariation.objects.count(), 2) def test_create_order_missing_product_color(self): response = self.create_order_request( product_color_id=None, lettering_items=[ {'title': 'Test', 'text': 'item1'} ] ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIsNone(ProductVariation.objects.first().product_color) def test_create_order_no_lettering_items(self): response = self.create_order_request( product_color_id=self.product_color.id, lettering_items=[] ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(LetteringItemVariation.objects.count(), 0)
Browse Marketplace