def prepare_data(self): self.connection = sqlite3.connect("bot_tests/data/sqlite/wake.db") cursor = self.connection.cursor() cursor.execute("DROP TABLE IF EXISTS sup_reserves") cursor.execute("DROP TABLE IF EXISTS users") self.connection.commit() self.supboard_adapter = SqliteSupboardAdapter(self.connection) self.user_adapter = SqliteUserAdapter(self.connection) for user in sup_users: self.user_adapter.append_data(user) self.reserves = [] start_time = time(datetime.today().time().hour + 1) for i in range(8): user = sup_users[i % 5] start_date = date.today() + timedelta(i - 2) supboard = Supboard(user, start_date=start_date, start_time=start_time, set_count=(i + 1)) supboard.count = i % 3 supboard = self.supboard_adapter.append_data(supboard) self.reserves.append(supboard) self.processor = SupboardProcessor(self.dp, self.state_manager, self.strings, self.supboard_adapter, self.user_adapter) self.processor.max_count = 6
async def test_equal(self): """Реализация сравнения резервирований""" reserve1 = Supboard(self.user, self.start_date, self.start_time, set_count=1, count=2) passed, alert = self.assert_params(reserve1, self.reserve) assert passed, alert reserve1 = Supboard(self.user, self.start_date, self.start_time, set_count=3) passed, alert = self.assert_params(reserve1, self.reserve) assert not passed, alert
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)
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_to_str_incomplete(self): """Строка незавершенного резервирования""" reserve = Supboard() passed, alert = self.assert_params(str(reserve), "") assert passed, alert