Skip to content

Commit

Permalink
fix score testen
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoutAllaert committed Mar 11, 2024
1 parent eec665e commit d38ac2a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion api/models/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
21 changes: 9 additions & 12 deletions api/tests/factories/indiening.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
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):
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")
1 change: 1 addition & 0 deletions api/tests/factories/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
class ScoreFactory(factory.django.DjangoModelFactory):
class Meta:
model = Score
score = factory.Faker('pyint')
8 changes: 3 additions & 5 deletions api/tests/models/test_score.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -23,4 +22,3 @@ def test_groep_field(self):

def test_str_method(self):
self.assertEqual(str(self.score), str(self.score.score))
"""

0 comments on commit d38ac2a

Please sign in to comment.