From d38ac2a47088dfa48784c180e4c5bc1dc705e025 Mon Sep 17 00:00:00 2001 From: arallaer Date: Mon, 11 Mar 2024 20:18:41 +0100 Subject: [PATCH] fix score testen --- api/models/score.py | 2 +- api/tests/factories/indiening.py | 21 +++++++++------------ api/tests/factories/score.py | 1 + api/tests/models/test_score.py | 8 +++----- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/api/models/score.py b/api/models/score.py index f8e959a9..bb89da2b 100644 --- a/api/models/score.py +++ b/api/models/score.py @@ -7,4 +7,4 @@ class Score(models.Model): groep = models.ForeignKey("Groep", on_delete=models.CASCADE) def __str__(self): - return self.score + return str(self.score) diff --git a/api/tests/factories/indiening.py b/api/tests/factories/indiening.py index 8a3c47f8..2cbae1f0 100644 --- a/api/tests/factories/indiening.py +++ b/api/tests/factories/indiening.py @@ -1,15 +1,10 @@ import factory from api.models.indiening import Indiening -from api.models.groep import Groep -from django.core.files.base import ContentFile +from api.tests.factories.groep import GroepFactory +from django.utils import timezone +from faker import Faker - -class GroepFactory(factory.django.DjangoModelFactory): - class Meta: - model = Groep - - # Add fields here. For example: - # field_name = factory.Faker('pystr') +fake = Faker() class IndieningFactory(factory.django.DjangoModelFactory): @@ -17,7 +12,9 @@ class Meta: model = Indiening indiener = factory.SubFactory(GroepFactory) - indieningsbestanden = factory.django.FileField( - from_path=ContentFile(b"file content") + indieningsbestanden = factory.django.FileField(data=b"file content") + tijdstip = factory.LazyFunction( + lambda: timezone.make_aware( + fake.date_time_between(start_date="+1d", end_date="+30d") + ) ) - tijdstip = factory.Faker("date_time_this_year") diff --git a/api/tests/factories/score.py b/api/tests/factories/score.py index 91087857..d0aef0a0 100644 --- a/api/tests/factories/score.py +++ b/api/tests/factories/score.py @@ -5,3 +5,4 @@ class ScoreFactory(factory.django.DjangoModelFactory): class Meta: model = Score + score = factory.Faker('pyint') diff --git a/api/tests/models/test_score.py b/api/tests/models/test_score.py index 2bb5fa99..70d99549 100644 --- a/api/tests/models/test_score.py +++ b/api/tests/models/test_score.py @@ -1,12 +1,11 @@ from django.test import TestCase -# from api.tests.factories.score import ScoreFactory -# from api.tests.factories.groep import GroepFactory -# from api.tests.factories.indiening import IndieningFactory +from api.tests.factories.score import ScoreFactory +from api.tests.factories.groep import GroepFactory +from api.tests.factories.indiening import IndieningFactory class ScoreModelTest(TestCase): - """ TODO def setUp(self): self.indiening = IndieningFactory.create() self.groep = GroepFactory.create() @@ -23,4 +22,3 @@ def test_groep_field(self): def test_str_method(self): self.assertEqual(str(self.score), str(self.score.score)) - """