def test_bad_login(self): with self.assertRaises(exceptions.APICallError): client = QGendaClient('username', 'password', 'company_key', api_version='v2', api_url='https://api.qgenda.com/', raise_errors=True) client.authenticate()
def test_bad_login(self): client = QGendaClient('username', 'password', 'company_key', api_version='v2', api_url='https://api.qgenda.com/', raise_errors=False) client.authenticate() self.assertTrue( all(key in client.auth_details for key in ["error", "error_description"]))
def test_shared_auth_basic(self): client1 = QGendaClient(raise_errors=True, leader=True) if not client1.use_caching: logger.warning('Caching is disabled and shared auth will not be used.') return client2 = QGendaClient(raise_errors=True, leader=False) response1 = client1.get_staff() response2 = client2.get_staff() self.assertTrue(response1.status_code, 200) self.assertTrue(response2.status_code, 200)
def test_shared_auth_excessive(self): leader = QGendaClient(raise_errors=True, leader=True) if not leader.use_caching: logger.warning('Caching is disabled and shared auth will not be used.') return response = leader.get_staff() self.assertTrue(response.status_code, 200) start = time.time() for i in range(100): client = QGendaClient(raise_errors=True, leader=False) response = client.get_staff() self.assertTrue(response.status_code, 200) latest = time.time() self.assertTrue(latest - start < 3, 'Caching test is taking too long. ' 'Caching is slow or improperly configured.')
def test_bad_config(self): with self.assertRaises(exceptions.ImproperlyConfigured): client = QGendaClient(raise_errors=True, use_caching=False, leader=False)
def setUpClass(cls): cls.client = QGendaClient(raise_errors=True)
def test_improper_config(self): with self.assertRaises(exceptions.ImproperlyConfigured): QGendaClient(None, 'password', company_key=None, raise_errors=True)