Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

31 rader
775 B

  1. import factory
  2. from api import models
  3. class UserFactory(factory.DjangoModelFactory):
  4. class Meta:
  5. model = models.User
  6. username = factory.Sequence(lambda n: 'username{0}'.format(n))
  7. first_name = factory.Faker('first_name')
  8. last_name = factory.Faker('last_name')
  9. email = factory.LazyAttribute(lambda a: '{0}.{1}@oslab.fr'.format(a.first_name, a.last_name).lower())
  10. password = factory.PostGenerationMethodCall('set_password', 'password')
  11. is_staff = False
  12. class AdminFactory(UserFactory):
  13. is_staff = True
  14. class SiteFactory(factory.DjangoModelFactory):
  15. class Meta:
  16. model = models.Site
  17. user = factory.SubFactory(UserFactory)
  18. name = 'facebook'
  19. password_length = 12
  20. password_type = 'strong'
  21. counter = 1