Selaa lähdekoodia

Don't use FACTORY_FOR when not needed

tags/v1.0.0
Krzysztof Klimonda 11 vuotta sitten
vanhempi
commit
26f9c76988
1 muutettua tiedostoa jossa 1 lisäystä ja 11 poistoa
  1. +1
    -11
      pinry/core/tests/helpers.py

+ 1
- 11
pinry/core/tests/helpers.py Näytä tiedosto

@@ -7,16 +7,11 @@ from django.test import TestCase
import factory
from taggit.models import Tag

from ..models import Image, Pin
from ...users.models import User


TEST_IMAGE_PATH = settings.SITE_ROOT + 'screenshot.png'


class UserFactory(factory.Factory):
FACTORY_FOR = User

username = factory.Sequence(lambda n: 'user_{}'.format(n))
email = factory.Sequence(lambda n: 'user_{}@example.com'.format(n))

@@ -29,21 +24,16 @@ class UserFactory(factory.Factory):
def set_user_permissions(self, create, extracted, **kwargs):
self.user_permissions = Permission.objects.filter(codename__in=['add_pin', 'add_image'])

class TagFactory(factory.Factory):
FACTORY_FOR = Tag

class TagFactory(factory.Factory):
name = factory.Sequence(lambda n: 'tag_{}'.format(n))


class ImageFactory(factory.Factory):
FACTORY_FOR = Image

image = factory.LazyAttribute(lambda a: File(open(TEST_IMAGE_PATH)))


class PinFactory(factory.Factory):
FACTORY_FOR = Pin

submitter = factory.SubFactory(UserFactory)
image = factory.SubFactory(ImageFactory)



Ladataan…
Peruuta
Tallenna