def test_set_load_with_invalid_body(self): data = dict_to_str({"load_average": "didn't validate me"}) resp = self.status_client.direct_update( worker_id=self.worker_id, worker_token=self.worker_token, body=data) self.assertEqual(resp.status_code, 400)
def get_keystone_v3_auth_resp(code=201, json=None, headers=None): auth_dict = json if not json: auth_dict = { 'token': { 'methods': [ 'password' ], 'roles': [], 'expires_at': '2015-02-25T18:42:16.989456Z', 'project': { 'id': 'some_project', 'name': 'admin' }, 'catalog': [], 'extras': {}, 'user': {}, 'issued_at': '2015-02-25T17:42:16.989488Z' } } if not headers: headers = { 'X-Subject-Token': 'some_token' } return stub( status_code=code, json=lambda: auth_dict, content=dict_to_str(auth_dict), headers=headers )
def _obj_to_json(self): the_dict = { 'resource_action': self.resource_action, 'resource_ref': self.resource_ref, 'impersonation_allowed': self.impersonation_allowed, 'resource_type': self.resource_type } return dict_to_str(the_dict)
def test_set_usage_with_invalid_body(self): worker_id = self.pairing_info.worker_id worker_token = self.pairing_info.worker_token data = dict_to_str({'disk_usage': 'random_str'}) resp = self.status_client.direct_update(worker_id=worker_id, worker_token=worker_token, body=data) self.assertEqual(resp.status_code, 400)
def get_keystone_v2_auth_resp(code=200, json=None, headers={}): auth_dict = json if not json: auth_dict = { 'access': { 'token': { 'id': 'some_token', 'tenant': { 'id': 'some_tenant' } } } } return stub( status_code=code, json=lambda: auth_dict, content=dict_to_str(auth_dict), headers=headers )
def _obj_to_json(self): usage = super(WorkerLoadAverage, self)._obj_to_dict() return dict_to_str({"load_average": usage})
def _obj_to_json(self): body = {"status": self.status, "system_info": self.system_info._obj_to_dict()} return dict_to_str({"worker_status": body})
def _obj_to_json(self): secret_dict = self.secret._obj_to_dict() return dict_to_str({'secret': secret_dict})
def _obj_to_json(self): return dict_to_str(self._obj_to_dict())
def _obj_to_json(self): secret_dict = self.meta._obj_to_dict() return dict_to_str({'type': self.order_type, 'meta': secret_dict})
def _obj_to_json(self): usage = super(WorkerLoadAverage, self)._obj_to_dict() return dict_to_str({'load_average': usage})
def _obj_to_json(self): body = { "status": self.status, "system_info": self.system_info._obj_to_dict() } return dict_to_str({"worker_status": body})
def _obj_to_json(self): usage = super(WorkerDiskUsage, self)._obj_to_dict() return dict_to_str({"disk_usage": usage})
def _obj_to_json(self): usage = super(WorkerDiskUsage, self)._obj_to_dict() return dict_to_str({'disk_usage': usage})