mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2026-02-04 16:50:38 +03:00
51
tests/integration/factories/bot.py
Normal file
51
tests/integration/factories/bot.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import time
|
||||
|
||||
import factory
|
||||
from faker import Faker
|
||||
|
||||
from tests.integration.factories.models import Chat, User
|
||||
|
||||
data = {
|
||||
"update_id": 957250703,
|
||||
"message": {
|
||||
"message_id": 417070387,
|
||||
"from": {
|
||||
"id": 1000,
|
||||
"is_bot": "false",
|
||||
"first_name": "William",
|
||||
"last_name": "Dalton",
|
||||
"username": "bolshakovfortunat",
|
||||
"language_code": "ru",
|
||||
},
|
||||
"chat": {"id": 1, "first_name": "Gabrielle", "last_name": "Smith", "username": "arefi_2019", "type": "private"},
|
||||
"date": time.time(),
|
||||
"text": "/chatid",
|
||||
"entities": [{"type": "bot_command", "offset": 0, "length": 7}],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
faker = Faker("ru_RU")
|
||||
|
||||
|
||||
class DeleteUserFactory(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 ChatFactory(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
|
||||
18
tests/integration/factories/models.py
Normal file
18
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