diff --git a/scipost_django/pins/factories.py b/scipost_django/pins/factories.py new file mode 100644 index 0000000000000000000000000000000000000000..bf88435f3661a195c114d2fad5c69cd4357655af --- /dev/null +++ b/scipost_django/pins/factories.py @@ -0,0 +1,42 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + +from django.contrib.contenttypes.models import ContentType +import factory + +from finances.models.subsidy import Subsidy +from .models import * +from common.faker import LazyRandEnum, fake, LazyAwareDate + + +class BaseNoteFactory(factory.django.DjangoModelFactory): + class Meta: + model = Note + + class Params: + regarding_object = factory.Trait( + regarding_content_type=factory.SelfAttribute("content_type"), + regarding_object_id=factory.SelfAttribute("object_id"), + ) + + title = factory.Faker("sentence", nb_words=4) + description = factory.Faker("text") + visibility = LazyRandEnum(Note.VISIBILITY_CHOICES) + author = factory.SubFactory("scipost.factories.ContributorFactory") + created = factory.Faker("date_time_this_year") + modified = factory.LazyAttribute( + lambda self: fake.aware.date_between(start_date=self.created, end_date="+1y") + ) + + +class BasePinFactory(factory.django.DjangoModelFactory): + class Meta: + model = Pin + + note = factory.SubFactory(BaseNoteFactory) + user = factory.SubFactory("scipost.factories.UserFactory") + due_date = factory.LazyAttribute( + lambda self: fake.aware.date_between( + start_date=self.note.created, end_date="+1y" + ) + ) diff --git a/scipost_django/pins/tests.py b/scipost_django/pins/tests.py deleted file mode 100644 index 7503e9a3c5a61d3da351a1edf6f69ca91e776780..0000000000000000000000000000000000000000 --- a/scipost_django/pins/tests.py +++ /dev/null @@ -1,6 +0,0 @@ -__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" -__license__ = "AGPL v3" - -from django.test import TestCase - -# Create your tests here. diff --git a/scipost_django/pins/tests/__init__.py b/scipost_django/pins/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/scipost_django/pins/tests/test_factories.py b/scipost_django/pins/tests/test_factories.py new file mode 100644 index 0000000000000000000000000000000000000000..a331f98d2ae43de1389da7a896556ed93bb845ff --- /dev/null +++ b/scipost_django/pins/tests/test_factories.py @@ -0,0 +1,17 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + +from django.test import TestCase +from ..factories import * + + +# class TestSubsidyNoteFactory(TestCase): +# def test_can_create_subsidy_notes(self): +# subsidy_note = SubsidyNoteFactory() +# self.assertIsNotNone(subsidy_note) + + +# class TestPinFactory(TestCase): +# def test_can_create_pins(self): +# pin = PinFactory() +# self.assertIsNotNone(pin)