Ejemplo n.º 1
0
 def test_get_job_bad_job_id(self):
     """ Negative test - Confirm we respond correctly to a broken id """
     response = compute.get_job(environment.ATHERA_API_TEST_BASE_URL,
                                environment.ATHERA_API_TEST_GROUP_ID,
                                environment.ATHERA_API_TEST_TOKEN,
                                "stilton")
     self.assertEqual(response.status_code, codes.bad_request)
Ejemplo n.º 2
0
 def test_get_job_random_job_id(self):
     """ Negative test - Confirm we respond correctly to a non-existent job id """
     response = compute.get_job(environment.ATHERA_API_TEST_BASE_URL,
                                environment.ATHERA_API_TEST_GROUP_ID,
                                environment.ATHERA_API_TEST_TOKEN,
                                str(uuid.uuid4()))
     self.assertEqual(response.status_code, codes.not_found)
Ejemplo n.º 3
0
    def wait_for_job_status(self, job_id, desired_statuses, timeout=60):
        job_status = ""
        wait_period = 10

        while timeout:
            time.sleep(wait_period)
            timeout -= wait_period

            response = compute.get_job(
                environment.ATHERA_API_TEST_BASE_URL,
                environment.ATHERA_API_TEST_GROUP_ID,
                self.token,
                job_id,
            )
            self.assertEqual(
                response.status_code, codes.ok,
                "Get job unexpected status code {}".format(
                    response.status_code))
            job_data = response.json()
            self.assertIn("id", job_data)
            self.assertEqual(job_id, job_data['id'])
            job_status = job_data['status']
            if job_status in desired_statuses:
                return None

        return "Waited 100 seconds for job to reach status {}, but job has status {}".format(
            desired_statuses, job_status)
Ejemplo n.º 4
0
 def test_get_job_wrong_group_and_job_id(self):
     """ Negative test - Confirm we cannot get a job which does not belong to us via another group """
     response = compute.get_job(
         environment.ATHERA_API_TEST_BASE_URL,
         environment.ATHERA_API_TEST_OTHER_GROUP_ID,
         environment.ATHERA_API_TEST_TOKEN,
         environment.ATHERA_API_TEST_OTHER_JOB_ID,
     )
     self.assertEqual(response.status_code, codes.forbidden)
Ejemplo n.º 5
0
 def test_get_job_wrong_job_id(self):
     """ Negative test - Confirm we cannot get a job which does not belong to us """
     response = compute.get_job(
         environment.ATHERA_API_TEST_BASE_URL,
         environment.ATHERA_API_TEST_GROUP_ID,
         self.token,
         environment.ATHERA_API_TEST_OTHER_JOB_ID,
     )
     self.assertEqual(response.status_code, codes.not_found)
Ejemplo n.º 6
0
 def test_get_job(self):
     """ Positive test """
     response = compute.get_job(
         environment.ATHERA_API_TEST_BASE_URL,
         environment.ATHERA_API_TEST_GROUP_ID,
         environment.ATHERA_API_TEST_TOKEN,
         environment.ATHERA_API_TEST_JOB_ID,
     )
     self.assertEqual(response.status_code, codes.ok)
     job_data = response.json()
     self.assertIn("id", job_data)
     self.assertEqual(environment.ATHERA_API_TEST_JOB_ID, job_data['id'])