improvements to router, y tests
This commit is contained in:
20
core/factories.py
Normal file
20
core/factories.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
|
||||
from factory import LazyAttribute, SubFactory
|
||||
from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyDateTime, FuzzyDate, FuzzyDecimal
|
||||
from factory.django import DjangoModelFactory
|
||||
|
||||
|
||||
class CustomUserFactory(DjangoModelFactory):
|
||||
|
||||
email = FuzzyText(length=6, suffix="@mail.com")
|
||||
full_name = FuzzyText(length=15, prefix="TestName_")
|
||||
role = FuzzyText(length=15, prefix="TestPosition_")
|
||||
notify = FuzzyChoice(choices=(True, False))
|
||||
provider = FuzzyText(length=15, prefix="TestProvider_")
|
||||
email_verified = True
|
||||
# company = None
|
||||
|
||||
class Meta:
|
||||
model = 'core.CustomUser'
|
||||
@@ -2,9 +2,17 @@ import logging
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from rest_framework_simplejwt.tokens import RefreshToken
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
def get_tokens_for_user(user):
|
||||
refresh = RefreshToken.for_user(user)
|
||||
|
||||
return {
|
||||
'refresh': str(refresh),
|
||||
'access': str(refresh.access_token),
|
||||
}
|
||||
|
||||
def get_auth_token(client, email, password):
|
||||
credentials = {
|
||||
|
||||
Reference in New Issue
Block a user