diff --git a/scipost_django/funders/factories.py b/scipost_django/funders/factories.py new file mode 100644 index 0000000000000000000000000000000000000000..eccd40edac4a61bd2eab153ce89913f705de4d92 --- /dev/null +++ b/scipost_django/funders/factories.py @@ -0,0 +1,27 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + +import random +from .models import * +import factory + + +class FunderFactory(factory.django.DjangoModelFactory): + class Meta: + model = Funder + + organization = factory.SubFactory("organizations.factories.OrganizationFactory") + name = factory.SelfAttribute("organization.name") + acronym = factory.SelfAttribute("organization.acronym") + identifier = factory.Faker("numerify", text="http://dx.doi.org/10.#####/#########") + + +class GrantFactory(factory.django.DjangoModelFactory): + class Meta: + model = Grant + + funder = factory.SubFactory(FunderFactory) + number = factory.Faker("isbn10") + recipient = factory.SubFactory("scipost.factories.ContributorFactory") + recipient_name = factory.SelfAttribute("recipient.profile.full_name") + further_details = factory.Faker("text") diff --git a/scipost_django/funders/tests/test_factories.py b/scipost_django/funders/tests/test_factories.py new file mode 100644 index 0000000000000000000000000000000000000000..be9bac9f84d0b2f536556698dbbf06c2d135ae25 --- /dev/null +++ b/scipost_django/funders/tests/test_factories.py @@ -0,0 +1,19 @@ +__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + + +from django.test import TestCase +from ..factories import * + + +# Create your tests here. +class TestFunderFactory(TestCase): + def test_can_create_funders(self): + funder = FunderFactory() + self.assertIsNotNone(funder) + + +class TestGrantFactory(TestCase): + def test_can_create_grants(self): + grant = GrantFactory() + self.assertIsNotNone(grant)