-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec1ef57
commit be13246
Showing
7 changed files
with
65 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import factory | ||
from django.contrib.auth.models import User | ||
from api.models.gebruiker import Gebruiker | ||
import factory | ||
from factory.django import DjangoModelFactory | ||
from factory import SubFactory, Faker | ||
|
||
|
||
class UserFactory(factory.django.DjangoModelFactory): | ||
class UserFactory(DjangoModelFactory): | ||
class Meta: | ||
model = User | ||
|
||
username = factory.Sequence(lambda n: f"user{n}") | ||
password = factory.PostGenerationMethodCall("set_password", "password") | ||
first_name = Faker('first_name') | ||
last_name = Faker('last_name') | ||
email = Faker('email') | ||
|
||
|
||
class GebruikerFactory(factory.django.DjangoModelFactory): | ||
class GebruikerFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Gebruiker | ||
|
||
user = factory.SubFactory(UserFactory) | ||
is_lesgever = False | ||
user = SubFactory(UserFactory) | ||
is_lesgever = Faker('boolean') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import factory | ||
from api.models.groep import Groep | ||
from factory.django import DjangoModelFactory | ||
from factory import SubFactory | ||
from api.tests.factories.gebruiker import GebruikerFactory | ||
from api.tests.factories.project import ProjectFactory | ||
|
||
|
||
class GroepFactory(factory.django.DjangoModelFactory): | ||
class GroepFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Groep | ||
|
||
project = factory.SubFactory(ProjectFactory) | ||
groep_id = factory.Sequence(lambda n: n) | ||
project = SubFactory(ProjectFactory) | ||
|
||
@factory.post_generation | ||
def students(self, create, extracted, **kwargs): | ||
def studenten(self, create, extracted, **kwargs): | ||
if not create: | ||
return | ||
|
||
if extracted: | ||
for student in extracted: | ||
self.students.add(student) | ||
self.studenten.add(student) | ||
else: | ||
self.students.add(GebruikerFactory()) | ||
self.students.add(GebruikerFactory()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
import factory | ||
from api.models.indiening import Indiening | ||
from api.tests.factories.groep import GroepFactory | ||
from api.models.indiening import Indiening, IndieningBestand | ||
from factory.django import DjangoModelFactory | ||
from factory import SubFactory, Faker | ||
from .groep import GroepFactory | ||
from django.utils import timezone | ||
from faker import Faker | ||
from factory.django import FileField | ||
|
||
fake = Faker() | ||
|
||
fake = Faker() | ||
|
||
class IndieningFactory(factory.django.DjangoModelFactory): | ||
class IndieningFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Indiening | ||
|
||
indiener = factory.SubFactory(GroepFactory) | ||
indieningsbestanden = factory.django.FileField(data=b"file content") | ||
indiening_id = factory.Sequence(lambda n: n) | ||
groep = SubFactory(GroepFactory) | ||
tijdstip = factory.LazyFunction( | ||
lambda: timezone.make_aware( | ||
fake.date_time_between(start_date="+1d", end_date="+30d") | ||
) | ||
) | ||
|
||
class IndieningBestandFactory(DjangoModelFactory): | ||
class Meta: | ||
model = IndieningBestand | ||
|
||
indiening_bestand_id = factory.Sequence(lambda n: n) | ||
indiening = SubFactory(IndieningFactory) | ||
bestand = FileField(filename='test.txt', data=b"file content") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
from django.utils import timezone | ||
import factory | ||
from api.models.project import Project | ||
from api.tests.factories.vak import VakFactory | ||
from faker import Faker | ||
|
||
fake = Faker() | ||
from django.core.files.base import ContentFile | ||
from factory.django import DjangoModelFactory | ||
from factory import SubFactory, Faker | ||
from django.utils import timezone | ||
from .vak import VakFactory | ||
|
||
fake = Faker('provider') | ||
|
||
class ProjectFactory(factory.django.DjangoModelFactory): | ||
class ProjectFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Project | ||
|
||
titel = factory.Faker("sentence", nb_words=4) | ||
description = factory.Faker("paragraph") | ||
opgavebestanden = factory.django.FileField(filename="opgave.pdf") | ||
vak = factory.SubFactory(VakFactory) | ||
project_id = factory.Sequence(lambda n: n) | ||
titel = Faker('title') | ||
beschrijving = Faker('paragraph') | ||
opgave_bestand = factory.django.FileField(data=b"file content") | ||
vak = SubFactory(VakFactory) | ||
deadline = factory.LazyFunction( | ||
lambda: timezone.make_aware( | ||
fake.date_time_between(start_date="+1d", end_date="+30d") | ||
) | ||
) | ||
max_score = Faker('random_int', min=10, max=30) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import factory | ||
from api.models.score import Score | ||
from factory.django import DjangoModelFactory | ||
from factory import SubFactory, Faker | ||
from api.tests.factories.indiening import IndieningFactory | ||
|
||
|
||
class ScoreFactory(factory.django.DjangoModelFactory): | ||
|
||
class ScoreFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Score | ||
|
||
score = factory.Faker("pyint") | ||
score_id = factory.Sequence(lambda n: n) | ||
score = Faker('random_int', min=0, max=100) | ||
indiening = SubFactory(IndieningFactory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import factory | ||
from api.models.vak import Vak | ||
from factory.django import DjangoModelFactory | ||
from factory import Faker | ||
from .gebruiker import GebruikerFactory | ||
|
||
|
||
class VakFactory(factory.django.DjangoModelFactory): | ||
class VakFactory(DjangoModelFactory): | ||
class Meta: | ||
model = Vak | ||
|
||
name = factory.Faker("word") | ||
vak_id = factory.Sequence(lambda n: n) | ||
naam = Faker('name') | ||
studenten = factory.RelatedFactory(GebruikerFactory, 'vak_gebruikers') | ||
lesgevers = factory.RelatedFactory(GebruikerFactory, 'vak_lesgevers') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters