mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2025-12-16 21:20:39 +03:00
microservices are able to run (#5)
This commit is contained in:
56
bot_microservice/tests/integration/factories/bot.py
Normal file
56
bot_microservice/tests/integration/factories/bot.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import string
|
||||
|
||||
import factory
|
||||
from faker import Faker
|
||||
from tests.integration.factories.models import Chat, User
|
||||
|
||||
faker = Faker("ru_RU")
|
||||
|
||||
|
||||
class BotUserFactory(factory.Factory):
|
||||
id = factory.Sequence(lambda n: 1000 + n)
|
||||
is_bot = False
|
||||
first_name = factory.Faker("first_name")
|
||||
last_name = factory.Faker("last_name")
|
||||
username = faker.profile(fields=["username"])["username"]
|
||||
language_code = "ru"
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
|
||||
|
||||
class BotChatFactory(factory.Factory):
|
||||
id = factory.Sequence(lambda n: 1 + n)
|
||||
first_name = factory.Faker("first_name")
|
||||
last_name = factory.Faker("last_name")
|
||||
username = faker.profile(fields=["username"])["username"]
|
||||
type = "private"
|
||||
|
||||
class Meta:
|
||||
model = Chat
|
||||
|
||||
|
||||
class BotInfoFactory(factory.DictFactory):
|
||||
token = factory.Faker(
|
||||
"bothify", text="#########:??????????????????????????-#????????#?", letters=string.ascii_letters
|
||||
) # example: 579694714:AAFpK8w6zkkUrD4xSeYwF3MO8e-4Grmcy7c
|
||||
payment_provider_token = factory.Faker(
|
||||
"bothify", text="#########:TEST:????????????????", letters=string.ascii_letters
|
||||
) # example: 579694714:TEST:K8w6zkkUrD4xSeYw
|
||||
chat_id = factory.Faker("random_int", min=10**8, max=10**9 - 1)
|
||||
super_group_id = factory.Faker("random_int", min=-(10**12) - 10**9, max=-(10**12)) # -1001838004577
|
||||
forum_group_id = factory.Faker("random_int", min=-(10**12) - 10**9, max=-(10**12))
|
||||
channel_name = factory.Faker("name")
|
||||
channel_id = factory.LazyAttribute(lambda obj: f"@{obj.channel_name}")
|
||||
name = factory.Faker("name")
|
||||
fake_username = factory.Faker("name")
|
||||
username = factory.LazyAttribute(lambda obj: "_".join(f"@{obj.fake_username}".split(" "))) # @Peter_Parker
|
||||
|
||||
class Meta:
|
||||
exclude = ("channel_name", "fake_username")
|
||||
|
||||
|
||||
class BotEntitleFactory(factory.DictFactory):
|
||||
type = "bot_command"
|
||||
offset = 0
|
||||
length = 7
|
||||
18
bot_microservice/tests/integration/factories/models.py
Normal file
18
bot_microservice/tests/integration/factories/models.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import NamedTuple
|
||||
|
||||
|
||||
class User(NamedTuple):
|
||||
id: int
|
||||
is_bot: bool
|
||||
first_name: str | None
|
||||
last_name: str | None
|
||||
username: str | None
|
||||
language_code: str
|
||||
|
||||
|
||||
class Chat(NamedTuple):
|
||||
id: int
|
||||
first_name: str | None
|
||||
last_name: str | None
|
||||
username: str
|
||||
type: str
|
||||
Reference in New Issue
Block a user