fix factory uuid method

This commit is contained in:
b1ek 2023-05-16 23:00:44 +10:00
parent 71241e7c63
commit c018b745ff
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import factory import factory
import random import random
import time, datetime import time, datetime, uuid
from django.db import models from django.db import models
@ -8,6 +8,10 @@ from pairent_app.models import Apartament, User
factory.Faker.override_default_locale('ru_RU'); factory.Faker.override_default_locale('ru_RU');
class UUID(factory.declarations.BaseDeclaration):
def evaluate(self, instance, step, extra):
return str(uuid.uuid4()).upper();
class OpenID_Address(factory.declarations.BaseDeclaration): class OpenID_Address(factory.declarations.BaseDeclaration):
def evaluate(self, instance, step, extra): def evaluate(self, instance, step, extra):
return ''.join(random.choices(list('abcdef12345678990'), k=6)) + "@vvsu.ru"; return ''.join(random.choices(list('abcdef12345678990'), k=6)) + "@vvsu.ru";
@ -129,5 +133,5 @@ class UserFactory(factory.django.DjangoModelFactory):
role = 's' role = 's'
openid_addr = OpenID_Address(); openid_addr = OpenID_Address();
openid_id = factory.faker.Faker('uuid'); openid_id = UUID();
photo_provider = Random(0,0,0, ['VVSU', 'GRAVATAR']); photo_provider = Random(0,0,0, ['VVSU', 'GRAVATAR']);