Skip to content

Commit

Permalink
test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Dec 8, 2023
1 parent 8d15d0a commit 4c34fd8
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 3 deletions.
20 changes: 20 additions & 0 deletions codeforlife/user/fixtures/classes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"model": "user.Class",
"pk": "AB123",
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"teacher": 1,
"school": 1
}
},
{
"model": "user.Class",
"pk": "AB456",
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"teacher": 2,
"school": 1
}
}
]
12 changes: 12 additions & 0 deletions codeforlife/user/fixtures/schools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"model": "user.School",
"pk": 1,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"name": "Example School",
"country": "UK",
"uk_county": "Surrey"
}
}
]
20 changes: 20 additions & 0 deletions codeforlife/user/fixtures/students.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"model": "user.Student",
"pk": 1,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"school": 1,
"klass": "AB123"
}
},
{
"model": "user.Student",
"pk": 2,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"school": 1,
"klass": "AB456"
}
}
]
6 changes: 4 additions & 2 deletions codeforlife/user/fixtures/teachers.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
"pk": 1,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"is_admin": true
"is_admin": true,
"school": 1
}
},
{
"model": "user.Teacher",
"pk": 2,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"is_admin": true
"is_admin": false,
"school": 1
}
}
]
31 changes: 31 additions & 0 deletions codeforlife/user/fixtures/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,36 @@
"password": "password",
"teacher": 2
}
},
{
"model": "user.User",
"pk": 3,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"first_name": "SpongeBob",
"password": "password",
"student": 1
}
},
{
"model": "user.User",
"pk": 4,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"first_name": "Patrick",
"password": "password",
"student": 2
}
},
{
"model": "user.User",
"pk": 5,
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"first_name": "Indiana",
"last_name": "Jones",
"email": "[email protected]",
"password": "password"
}
}
]
1 change: 1 addition & 0 deletions codeforlife/user/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def create_superuser(self, password: str, first_name: str, **fields):
)

# TODO: is last name required for teachers?
# TODO: are students allowed to have a last name?
last_name = models.CharField(
_("last name"),
max_length=150,
Expand Down
6 changes: 5 additions & 1 deletion codeforlife/user/tests/models/test_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.test import TestCase
from django.utils import timezone

from ...models import User
from ...models import Class, User


class TestAbstract(TestCase):
Expand All @@ -18,9 +18,13 @@ class TestAbstract(TestCase):
Abstract model path: codeforlife.models
"""

# TODO: group fixtures by scenarios, not model classes.
fixtures = [
"users",
"teachers",
"schools",
"classes",
"students",
]

def setUp(self):
Expand Down

0 comments on commit 4c34fd8

Please sign in to comment.