Implement tag models

This commit is contained in:
Eliot Berriot 2019-07-08 15:26:14 +02:00
parent c170ee9394
commit 6dde4b73cd
28 changed files with 1034 additions and 141 deletions

View file

@ -42,11 +42,20 @@ class InvitationFactory(NoUpdateOnCreate, factory.django.DjangoModelFactory):
expired = factory.Trait(expiration_date=factory.LazyFunction(timezone.now))
class PasswordSetter(factory.PostGenerationMethodCall):
def call(self, instance, step, context):
if context.value_provided and context.value is None:
# disable setting the password, it's set by hand outside of the factory
return
return super().call(instance, step, context)
@registry.register
class UserFactory(factory.django.DjangoModelFactory):
username = factory.Sequence(lambda n: "user-{0}".format(n))
email = factory.Sequence(lambda n: "user-{0}@example.com".format(n))
password = factory.PostGenerationMethodCall("set_password", "test")
username = factory.Faker("user_name")
email = factory.Faker("email")
password = password = PasswordSetter("set_password", "test")
subsonic_api_token = None
groups = ManyToManyFromList("groups")
avatar = factory.django.ImageField()