Skip to content
Snippets Groups Projects
Commit 4d880c21 authored by fu2662cw's avatar fu2662cw :speech_balloon:
Browse files

Add fixtures to create on object per model

parent 15ab2e11
No related branches found
No related tags found
No related merge requests found
unisportomat/media/logo.png

18.3 KiB

unisportomat/media/test_image.png

21.7 KiB

[
{
"model": "quiz.calltomove",
"pk": 1,
"fields": {
"text": "Kreise deine Arme vor der nächsten Frage 3x nach hinten",
"image": "test_image.png"
}
}
]
\ No newline at end of file
[
{
"model": "quiz.criterion",
"pk": 1,
"fields": {
"name": "Outdoorsport"
}
}
]
\ No newline at end of file
[
{
"model": "quiz.criterionrating",
"pk": 1,
"fields": {
"rating": 1,
"criterion": 1,
"sport": 1
}
}
]
\ No newline at end of file
unisportomat/quiz/fixtures/images/logo.png

18.3 KiB

[
{
"model": "quiz.knowledgesnack",
"pk": 1,
"fields": {
"text": "Dass Treppensteigen fast 5x so viele Kalorien verbrennt, als die Nutzung des Aufzuges?",
"image": "logo.png"
}
}
]
\ No newline at end of file
[
{
"model": "quiz.question",
"pk": 1,
"fields": {
"text": "Ich mache am liebsten draußen Sport"
}
}
]
\ No newline at end of file
...@@ -197,10 +197,55 @@ class FixturesTest(TestCase): ...@@ -197,10 +197,55 @@ class FixturesTest(TestCase):
They can be used in automated tests, but also in development. They can be used in automated tests, but also in development.
""" """
fixtures = ["sports.json"] fixtures = [
"sports.json",
"criteria.json",
"criterion_ratings.json",
"questions.json",
"calls_to_move.json",
"knowledge_snacks.json",
]
def test_sports_created_by_fixture(self): def test_sports_created_by_fixture(self):
"""If the fixture is loaded there exists a sport with the given data.""" """If the sports fixture is loaded there exists a sport with the given data."""
sport = Sport.objects.get(pk=1) sport = Sport.objects.get(pk=1)
self.assertEqual(sport.name, "Jiu Jitsu") self.assertEqual(sport.name, "Jiu Jitsu")
self.assertEqual(sport.url, "http://www.test.de") self.assertEqual(sport.url, "http://www.test.de")
def test_criterion_created_by_fixture(self):
"""If the criteria fixture is loaded there exists a criterion with the given data"""
criterion = Criterion.objects.get(pk=1)
self.assertEqual(criterion.name, "Outdoorsport")
def test_criterion_rating_created_by_fixture(self):
"""If the criterion_ratings fixture is loaded the given sport has a corresponding rating"""
criterion = Criterion.objects.get(name="Outdoorsport")
sport = Sport.objects.get(name="Jiu Jitsu")
self.assertEqual(sport.get_rating(criterion), 1)
def test_question_created_by_fixture(self):
"""If the questions fixture is loaded there exists a question with the given data"""
question = Question.objects.get(pk=1)
criterion = Criterion.objects.get(name="Outdoorsport")
self.assertEqual(question.text, "Ich mache am liebsten draußen Sport")
self.assertEqual(question.criterion, criterion)
def test_call_to_move_created_by_fixture(self):
"""If the call to move fixture is loaded there exists a call to move with the given data"""
call_to_move = CallToMove.objects.get(pk=1)
self.assertEqual(
call_to_move.text, "Kreise deine Arme vor der nächsten Frage 3x nach hinten"
)
self.assertEqual(call_to_move.image.name, "test_image.png")
def test_knowledge_snack_created_by_fixture(self):
"""
If the knowledge snack fixture is loaded there exists a knowledge snack with the given data
"""
knowledge_snack = KnowledgeSnack.objects.get(pk=1)
self.assertEqual(
knowledge_snack.text,
"Dass Treppensteigen fast 5x so viele Kalorien verbrennt, "
"als die Nutzung des Aufzuges?",
)
self.assertEqual(knowledge_snack.image.name, "logo.png")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment