def get(url, headers=None, params=None, timeout=default_timeout): response = requests.get(url, headers=headers, params=params, timeout=timeout) code = response.status_code if code == requests.codes.ok: body = response.json() if body: return Entity.from_object(body)
def post(url, data=None, headers=None, params=None, timeout=default_timeout): response = requests.post(url, data=data, headers=headers, params=params, timeout=timeout) code = response.status_code if code == requests.codes.ok or \ code == requests.codes.created: body = response.json() if body: return Entity.from_object(body)
def to_entity(self): return Entity.from_object({ 'contract_id': self.contract_id, 'plan_id': self.plan_id, 'license_key': self.license_key, 'customer_id': self.customer_id, 'contract_type': self.contract_type, 'contract_status': self.contract_status, 'auto_renew_status': self.auto_renew_status, 'license_start_date': self.license_start_date.__str__(), 'license_end_date': self.license_end_date.__str__(), 'last_updated_vendor': self.last_updated_vendor })
def to_entity(self): return Entity.from_object({ 'user_id': self.user_id, 'user_name': self.username, 'age': self.age })
def test_payload_is_entity_in_success_response(self): entity = Entity.from_object({'key': 'test'}) response = SuccessResponse(data=entity) assert len(response['data'].keys()) is not 0
def mockreturn(_id): return Entity.from_object({ 'id': _id, 'user_name': 'Test', 'age': 15 })
def post(self): args = user_post_parser.parse_args() new_id = user_service.create_user(name=args['user_name'], age=args['age']) return SuccessResponse(data=Entity.from_object({'id': new_id})), 201