Beispiel #1
0
    def prepare_data(self):
        self.connection = sqlite3.connect("bot_tests/data/sqlite/wake.db")
        cursor = self.connection.cursor()

        cursor.execute("DROP TABLE IF EXISTS wake_reserves")
        cursor.execute("DROP TABLE IF EXISTS users")
        self.connection.commit()

        self.wake_adapter = SqliteWakeAdapter(self.connection)
        self.user_adapter = SqliteUserAdapter(self.connection)

        for user in wake_users:
            self.user_adapter.append_data(user)

        self.reserves = []
        start_time = time(datetime.today().time().hour + 1)
        for i in range(8):
            user = wake_users[i % 5]
            start_date = date.today() + timedelta(i - 2)
            wake = Wake(user,
                        start_date=start_date,
                        start_time=start_time,
                        set_count=(i + 1))
            wake.board = i % 2
            wake.hydro = i % 3
            wake = self.wake_adapter.append_data(wake)
            self.reserves.append(wake)
        self.processor = WakeProcessor(self.dp, self.state_manager,
                                       self.strings, self.wake_adapter,
                                       self.user_adapter)
Beispiel #2
0
    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