示例#1
0
 def remote_query_job(self, url, params):
     self.client = None
     self.sim = None
     with requests_mock.Mocker() as mock:
         print("mocking: ", url)
         text = "FAIL"
         mock.register_uri("GET", url, text=text)
         return Compute.remote_query_job(self, url, params)
示例#2
0
 def remote_query_job(self, url, params):
     with requests_mock.Mocker() as mock:
         if self.num_times_to_wait > 0:
             text = "NO"
         else:
             text = "YES"
         mock.register_uri("GET", url, text=text)
         self.num_times_to_wait -= 1
         return Compute.remote_query_job(self, url, params)
示例#3
0
 def remote_query_job(self, url, params):
     # Need to login as the comp-api-user
     self.client.login(username=self.user, password=self.password)
     if isinstance(self.client, APIClient):
         format_kwarg = {"format": "json"}
     else:
         format_kwarg = {"content_type": "application/json"}
     resp = self.client.put("/outputs/api/",
                            data=dict(json.loads(self.outputs),
                                      **{"job_id": self.sim.job_id}),
                            **format_kwarg)
     assert resp.status_code == 200
     self.client = None
     self.sim = None
     with requests_mock.Mocker() as mock:
         text = "NO"
         mock.register_uri("GET", url, text=text)
         return Compute.remote_query_job(self, url, params)
示例#4
0
 def remote_query_job(self, url):
     # Need to login as the comp-api-user
     self.client.login(username=self.user, password=self.password)
     if isinstance(self.client, APIClient):
         format_kwarg = {"format": "json"}
     else:
         format_kwarg = {"content_type": "application/json"}
     resp = self.client.put(
         "/outputs/api/",
         data=dict(json.loads(self.outputs), **{"job_id": self.sim.job_id}),
         **format_kwarg,
     )
     if resp.status_code != 200:
         raise CallbackException(
             f"Status code: {resp.status_code}\n {json.dumps(resp.data, indent=4)}"
         )
     self.client = None
     self.sim = None
     with requests_mock.Mocker() as mock:
         text = "NO"
         mock.register_uri("GET", url, text=text)
         return Compute.remote_query_job(self, url)