-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ class UserAdmin(BaseUserAdmin): | |
|
||
|
||
admin.site.register(models.User, UserAdmin) | ||
admin.site.register(models.Recipe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.14 on 2024-07-14 01:40 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Recipe', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=255)), | ||
('description', models.TextField(blank=True)), | ||
('time_minutes', models.IntegerField()), | ||
('price', models.DecimalField(decimal_places=2, max_digits=5)), | ||
('link', models.CharField(blank=True, max_length=255)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
from decimal import Decimal | ||
|
||
from django.test import TestCase | ||
from django.contrib.auth import get_user_model | ||
|
||
from core import models | ||
|
||
|
||
class ModelTests(TestCase): | ||
""" | ||
Test User Model | ||
""" | ||
|
||
def test_create_user_with_email_successful(self): | ||
email = '[email protected]' | ||
|
@@ -43,3 +50,22 @@ def test_create_superuser(self): | |
|
||
self.assertTrue(user.is_superuser) | ||
self.assertTrue(user.is_staff) | ||
|
||
""" | ||
Test Recipe Model | ||
""" | ||
|
||
def test_create_recipe(self): | ||
user = get_user_model().objects.create_user( | ||
'[email protected]', | ||
'testpass123' | ||
) | ||
recipe = models.Recipe.objects.create( | ||
user=user, | ||
title='Sample recipe name', | ||
time_minutes=5, | ||
price=Decimal('5.50'), | ||
description='Sample recipe description' | ||
) | ||
|
||
self.assertEqual(str(recipe), recipe.title) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class RecipeConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'recipe' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |