SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit d94c0ecc authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add scaffold factories for all pins models

parent 2dfc33a3
No related branches found
No related tags found
No related merge requests found
__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"
)
)
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.test import TestCase
# Create your tests here.
__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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment