Exemple #1
0
    def test_freeing_table(self):
        user_id = "user-1"
        table_id = "test-1"

        table = Table(table_id)
        table.redis_client = self.mock_redis
        table.claim(user_id)

        self.assertTrue(table.is_used_now())
        table.free(user_id)
        self.assertFalse(table.is_used_now())
        self.assertEqual(len(table.check()), 2)
Exemple #2
0
    def test_claiming_table(self, m_datetime):
        m_datetime.now = lambda: 12
        user_id = "user-1"
        table_id = "test-1"

        table = Table(table_id)
        table.redis_client = self.mock_redis
        table.claim(user_id)

        table_status = table.check()[0]
        desired_output = {
            'action': 'claim',
            'user_id': 'user-1',
            'how_long': datetime.timedelta(0, 1800),
            'created': 12
        }

        self.assertEqual(table_status, desired_output)
        self.assertTrue(table.is_used_now())