def test_get_session_wrong_group(self): """ Negative test - Confirm we cannot get a real session which does not belong to us, even if we use the right group """ response = sessions.get_session( environment.ATHERA_API_TEST_BASE_URL, environment.ATHERA_API_TEST_OTHER_GROUP_ID, self.token, environment.ATHERA_API_TEST_OTHER_SESSION_ID, ) self.assertEqual(response.status_code, codes.forbidden)
def test_get_session_wrong_session(self): """ Negative test - Confirm we cannot get a real session which does not belong to us """ response = sessions.get_session( environment.ATHERA_API_TEST_BASE_URL, environment.ATHERA_API_TEST_GROUP_ID, self.token, environment.ATHERA_API_TEST_OTHER_SESSION_ID, ) self.assertEqual(response.status_code, codes.not_found)
def test_get_session_bad_session(self): """ Negative test - Confirm we respond correctly to a non-existent session id """ response = sessions.get_session( environment.ATHERA_API_TEST_BASE_URL, environment.ATHERA_API_TEST_GROUP_ID, self.token, str(uuid.uuid4()), ) self.assertEqual(response.status_code, codes.not_found)
def test_get_session(self): """ Positive test """ response = sessions.get_session( environment.ATHERA_API_TEST_BASE_URL, environment.ATHERA_API_TEST_GROUP_ID, self.token, environment.ATHERA_API_TEST_SESSION_ID, ) self.assertEqual(response.status_code, codes.ok) session_data = response.json() self.assertIn("id", session_data) self.assertEqual(environment.ATHERA_API_TEST_SESSION_ID, session_data['id'])
def test_start_and_stop_session(self): """ Positive test """ payload = sessions.make_session_request( environment.ATHERA_API_TEST_USER_ID, environment.ATHERA_API_TEST_GROUP_ID, environment.ATHERA_API_TEST_INTERACTIVE_APP_ID, environment.ATHERA_API_TEST_REGION, 1920, 1080, 72, "APITest", ) response = sessions.start_session( environment.ATHERA_API_TEST_BASE_URL, environment.ATHERA_API_TEST_GROUP_ID, self.token, payload ) self.assertEqual(response.status_code, codes.created) # 201 = created: received and will be processed data = response.json() session_id = data['id'] print(session_id) # Wait for ready timeout = 600 wait_period = 10 while timeout: response = sessions.get_session( environment.ATHERA_API_TEST_BASE_URL, environment.ATHERA_API_TEST_GROUP_ID, self.token, session_id, ) self.assertEqual(response.status_code, codes.ok) data = response.json() session_status = data['status'] self.assertNotIn(session_status, sessions.failed_status) self.assertNotIn(session_status, sessions.completed_status) if session_status in sessions.ready_status: break print("{}s {}".format(timeout, session_status)) time.sleep(wait_period) timeout -= wait_period self.assertGreater(timeout, 0) response = sessions.stop_session( environment.ATHERA_API_TEST_BASE_URL, environment.ATHERA_API_TEST_GROUP_ID, self.token, session_id, ) self.assertEqual(response.status_code, codes.ok)