def setUp(self): self.user = User("Firstname", phone_number="+777") self.start_date = date.today() self.start_time = time(10, 0, 0) self.minutes = 5 # продолжительность self.reserve = Reserve(self.user, self.start_date, self.start_time)
async def test_diplay_name_full(self): """Формирование отображаемого имени с отчеством""" user = User("Firstname", "Lastname", "Middlename", None, "+7999555443322", 9876, 3456) passed, alert = self.assert_params(user.displayname, "Lastname Firstname Middlename") assert passed, alert
async def test_to_str(self): """Строка""" user = User("Firstname", "Lastname", "Middlename", None, "+7999555443322", 9876, 3456) passed, alert = self.assert_params(str(user), "Lastname Firstname Middlename") assert passed, alert
def setUp(self): self.drop_table() self.adapter = SqliteUserAdapter(self.connection) self.user = User(firstname="Firstname", lastname="Lastname", middlename="Middlename", phone_number="914", telegram_id=586)
def setUp(self): self.user = User("Firstname", phone_number="+777") self.start_date = date.today() self.start_time = time(10, 0, 0) self.minutes = 30 # продолжительность self.set_count = 1 self.reserve = Supboard(self.user, self.start_date, self.start_time, set_count=1, count=2)
def setUp(self): self.drop_table() self.adapter = SqliteSupboardAdapter(self.connection) self.user = User("Firstname", telegram_id=586, phone_number="+77777") self.start_date = date.today() self.start_time = time(10, 0, 0) self.set_count = 3 self.reserve = Supboard(self.user, self.start_date, self.start_time, set_count=3, count=2)
def setUp(self): self.drop_table() self.adapter = PostgressWakeAdapter(self.connection) self.user = User("Firstname", telegram_id=586, phone_number="+777") self.start_date = date.today() self.start_time = time(10, 0, 0) self.set_count = 3 self.reserve = Wake(self.user, self.start_date, self.start_time, set_count=3, board=1, hydro=1)
async def test_get_concurrent_reserves(self): self.supboards = [] for i in range(8): start_time = time(10 + i) user = User(f"Firstname{i}", phone_number="+7777") user.lastname = f"Lastname{i}" user.telegram_id = int(str(i) * 8) start_date = date.today() supboard = Supboard(user, start_date=start_date, start_time=start_time, set_count=(i + 1), count=(i % 3)) self.supboards.append(supboard) self.adapter.append_data(supboard) supboard = self.supboards[1] supboard.set_count = 3 rows = list(self.adapter.get_concurrent_reserves(self.supboards[1])) passed, alert = self.assert_params(len(rows), 2) assert passed, alert
async def test_get_concurrent_count(self): self.wakes = [] for i in range(8): start_time = time(10 + i) user = User(f"Firstname{i}", phone_number="+7777") user.lastname = f"Lastname{i}" user.telegram_id = int(str(i) * 8) start_date = date.today() wake = Wake(user, start_date=start_date, start_time=start_time, set_count=(i + 1)) wake.board = i % 2 wake.hydro = i % 3 self.wakes.append(wake) self.adapter.append_data(wake) wake = self.wakes[1] wake.set_count = 10 count = self.adapter.get_concurrent_count(self.wakes[1]) passed, alert = self.assert_params(count, 2) assert passed, alert
async def test_set_properties(self): user = User("Firstname") user.firstname = "Newname" user.lastname = "Lastname1" user.middlename = "Middlename1" user.displayname = "Displayname1" user.phone_number = "+7999555443311" user.telegram_id = 1234 user.user_id = 9876 passed, alert = self.assert_params(user.firstname, "Newname") assert passed, alert passed, alert = self.assert_params(user.lastname, "Lastname1") assert passed, alert passed, alert = self.assert_params(user.middlename, "Middlename1") assert passed, alert passed, alert = self.assert_params(user.displayname, "Displayname1") assert passed, alert passed, alert = self.assert_params(user.phone_number, "+7999555443311") assert passed, alert passed, alert = self.assert_params(user.telegram_id, 1234) assert passed, alert passed, alert = self.assert_params(user.user_id, 9876) assert passed, alert
async def test_create_properties(self): user = User("Firstname", "Lastname", "Middlename", "Displayname", "+7999555443322", 9876, 3456) passed, alert = self.assert_params(user.firstname, "Firstname") assert passed, alert passed, alert = self.assert_params(user.lastname, "Lastname") assert passed, alert passed, alert = self.assert_params(user.middlename, "Middlename") assert passed, alert passed, alert = self.assert_params(user.displayname, "Displayname") assert passed, alert passed, alert = self.assert_params(user.phone_number, "+7999555443322") assert passed, alert passed, alert = self.assert_params(user.telegram_id, 9876) assert passed, alert passed, alert = self.assert_params(user.user_id, 3456) assert passed, alert passed, alert = self.assert_params(user.is_admin, False) assert passed, alert
from wakebot.entities import User users = [] users.append( User(firstname="AdminName1", is_admin=True, telegram_id=101, phone_number="+7101")) users.append( User(firstname="UserName1", is_admin=False, telegram_id=201, phone_number="+7201")) users.append( User(firstname="UserName2", is_admin=False, telegram_id=202, phone_number="+7202")) users.append( User(firstname="UserName3", is_admin=False, telegram_id=203, phone_number="+7203")) users.append( User(firstname="AdminName2", is_admin=True, telegram_id=102, phone_number="+7102"))
async def test_diplay_name_firstname_only(self): """Формирование отображаемого имени только из имени""" """Формирование отображаемого имени без фамилии""" user = User("Firstname") passed, alert = self.assert_params(user.displayname, "Firstname") assert passed, alert
async def test_diplay_name_without_lastname(self): """Формирование отображаемого имени без фамилии""" user = User("Firstname", None, "Middlename") passed, alert = self.assert_params(user.displayname, "Firstname Middlename") assert passed, alert
async def test_diplay_name_without_middlename(self): """Формирование отображаемого имени без отчества""" user = User("Firstname", "Lastname") passed, alert = self.assert_params(user.displayname, "Lastname Firstname") assert passed, alert