From 945e60ad49734ba801300b98cfc0557c7b538b86 Mon Sep 17 00:00:00 2001 From: Noah Jonah Gente <fu2662cw@mi.fu-berlin.de> Date: Sat, 5 Jun 2021 17:42:18 +0200 Subject: [PATCH] Add fixture and test for one sport --- unisportomat/quiz/fixtures/sports.json | 10 ++++++++++ unisportomat/quiz/tests.py | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 unisportomat/quiz/fixtures/sports.json diff --git a/unisportomat/quiz/fixtures/sports.json b/unisportomat/quiz/fixtures/sports.json new file mode 100644 index 0000000..f941796 --- /dev/null +++ b/unisportomat/quiz/fixtures/sports.json @@ -0,0 +1,10 @@ +[ + { + "model": "quiz.sport", + "pk": 1, + "fields": { + "name": "Jiu Jitsu", + "url": "http://www.test.de" + } + } +] \ No newline at end of file diff --git a/unisportomat/quiz/tests.py b/unisportomat/quiz/tests.py index a81a66b..3904e0c 100644 --- a/unisportomat/quiz/tests.py +++ b/unisportomat/quiz/tests.py @@ -188,3 +188,18 @@ class CriterionAndQuestionModelTest(TestCase): Question(text=text, criterion=self.criterion).save() test_question = Question.objects.first() self.assertEqual(test_question.text, text) + + +class FixturesTest(TestCase): + """ + These are the tests for the fixtures in quiz/fixtures. + Fixtures can be used to populate the database which test data. + They can be used in automated tests, but also in development. + """ + fixtures = ["sports.json"] + + def test_sports_created_by_fixture(self): + """ If the fixture is loaded there exists a sport with the given data. """ + sport = Sport.objects.get(pk=1) + self.assertEqual(sport.name, "Jiu Jitsu") + self.assertEqual(sport.url, "http://www.test.de") -- GitLab