def add_member(self, image_id, member_id, requestslib_kwargs=None): """@summary: Add a member to an image""" url = '{0}/images/{1}/members'.format(self.base_url, image_id) member = Member(member_id=member_id) return self.request('POST', url, request_entity=member, response_entity_type=Member, requestslib_kwargs=requestslib_kwargs)
def update_member(self, image_id, member_id, status): url = '{base_url}/images/{image_id}/members/{member_id}'.format( base_url=self.base_url, image_id=image_id, member_id=member_id) member = Member(image_id=image_id, member_id=member_id, status=status) return self.request('PUT', url, request_entity=member, response_entity_type=Member)
def add_member(self, image_id, member_id): url = '{base_url}/images/{image_id}/members'.format( base_url=self.base_url, image_id=image_id) member = Member(image_id=image_id, member_id=member_id) return self.request('POST', url, request_entity=member, response_entity_type=Member)
def update_member(self, image_id, member_id, status, requestslib_kwargs=None): """@summary: Update a member for an image""" url = '{0}/images/{1}/members/{2}'.format(self.base_url, image_id, member_id) member = Member(status=status) return self.request('PUT', url, request_entity=member, response_entity_type=Member, requestslib_kwargs=requestslib_kwargs)
def setup_class(cls): cls.raw_member_str = ('''{ "status": "accepted", "created_at": "2013-09-17T12:51:03Z", "updated_at": "2013-09-17T13:14:28Z", "image_id": "af61731b-7181-4831-821f-b868df122f5a", "member_id": "someguy", "schema": "/v2/schemas/member" }''') cls.member_obj = \ Member(member_id='someguy', status='accepted', created_at=datetime.strptime('2013-09-17T12:51:03Z', '%Y-%m-%dT%H:%M:%SZ'), updated_at=datetime.strptime('2013-09-17T13:14:28Z', '%Y-%m-%dT%H:%M:%SZ'), image_id='af61731b-7181-4831-821f-b868df122f5a')
def setup_class(cls): cls.raw_members_str = ('''{ "members": [ { "status": "accepted", "created_at": "2013-09-17T12:51:03Z", "updated_at": "2013-09-17T13:14:28Z", "image_id": "af61731b-7181-4831-821f-b868df122f5a", "member_id": "someguy", "schema": "/v2/schemas/member" }], "schema": "/v2/schemas/members" }''') cls.members_obj = [ (Member(member_id='someguy', status='accepted', created_at='2013-09-17T12:51:03Z', updated_at='2013-09-17T13:14:28Z', image_id='af61731b-7181-4831-821f-b868df122f5a', schema="/v2/schemas/member")) ]
def test_json_to_obj(self): deserialized_obj = Member._json_to_obj(self.raw_member_str) assert self.member_obj == deserialized_obj
def test_json_to_obj(self): deserialized_obj = Member._json_to_obj(self.raw_member_str) assert self.member_obj == deserialized_obj