Exemple #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)
Exemple #2
0
    async def test_equal(self):
        """Реализация сравнения резервирований"""
        reserve1 = Wake(self.user,
                        self.start_date,
                        self.start_time,
                        set_count=3,
                        board=1,
                        hydro=1)

        passed, alert = self.assert_params(reserve1, self.reserve)
        assert passed, alert

        reserve1 = Wake(
            self.user,
            self.start_date,
            self.start_time,
        )
        passed, alert = self.assert_params(reserve1, self.reserve)
        assert not passed, alert
Exemple #3
0
 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 = 3
     self.reserve = Wake(self.user,
                         self.start_date,
                         self.start_time,
                         set_count=3,
                         board=1,
                         hydro=1)
Exemple #4
0
 def setUp(self):
     self.drop_table()
     self.adapter = SqliteWakeAdapter(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 = Wake(self.user,
                         self.start_date,
                         self.start_time,
                         set_count=3,
                         board=1,
                         hydro=1)
Exemple #5
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
Exemple #6
0
 async def test_to_str_incomplete(self):
     """Строка незавершенного резервирования"""
     reserve = Wake()
     passed, alert = self.assert_params(str(reserve), "")
     assert passed, alert