From c018b745ff60893d24797a1180ad27d0237a882b Mon Sep 17 00:00:00 2001 From: b1ek Date: Tue, 16 May 2023 23:00:44 +1000 Subject: [PATCH] fix factory uuid method --- pairent_backend/pairent_app/factories.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pairent_backend/pairent_app/factories.py b/pairent_backend/pairent_app/factories.py index db0cd00..e6d046a 100644 --- a/pairent_backend/pairent_app/factories.py +++ b/pairent_backend/pairent_app/factories.py @@ -1,6 +1,6 @@ import factory import random -import time, datetime +import time, datetime, uuid from django.db import models @@ -8,6 +8,10 @@ from pairent_app.models import Apartament, User 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): def evaluate(self, instance, step, extra): return ''.join(random.choices(list('abcdef12345678990'), k=6)) + "@vvsu.ru"; @@ -129,5 +133,5 @@ class UserFactory(factory.django.DjangoModelFactory): role = 's' openid_addr = OpenID_Address(); - openid_id = factory.faker.Faker('uuid'); + openid_id = UUID(); photo_provider = Random(0,0,0, ['VVSU', 'GRAVATAR']); \ No newline at end of file