<s> """<STR_LIT>""" <EOL> import calendar <EOL> import time <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . images . common . types import ImageMemberStatus , Schemas <EOL> from cloudroast . images . fixtures import ImagesFixture <EOL> class TestImageMemberLifeCycle ( ImagesFixture ) : <EOL> @ tags ( type = '<STR_LIT>' , regression = '<STR_LIT:true>' ) <EOL> def test_image_member_life_cycle ( self ) : <EOL> """<STR_LIT>""" <EOL> member_id = self . alt_tenant_id <EOL> image = self . images_behavior . create_image_via_task ( ) <EOL> response = self . images_client . list_members ( image . id_ ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> get_members_resp = response . entity <EOL> self . assertIsNotNone ( get_members_resp ) <EOL> self . assertListEqual ( get_members_resp , [ ] ) <EOL> response = self . images_client . add_member ( image . id_ , member_id ) <EOL> image_member_creation_time_in_sec = calendar . timegm ( time . gmtime ( ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> member_resp = response . entity <EOL> self . assertIsNotNone ( member_resp ) <EOL> created_at_in_sec = calendar . timegm ( time . strptime ( str ( member_resp . created_at ) , <EOL> "<STR_LIT>" ) ) <EOL> delta_in_image_member_created_time = abs ( created_at_in_sec - image_member_creation_time_in_sec ) <EOL> updated_at_in_sec = calendar . timegm ( time . strptime ( str ( member_resp . updated_at ) , <EOL> "<STR_LIT>" ) ) <EOL> delta_in_image_member_updated_time = abs ( updated_at_in_sec - image_member_creation_time_in_sec ) <EOL> self . assertLessEqual ( delta_in_image_member_created_time , <NUM_LIT> ) <EOL> self . assertEqual ( member_resp . image_id , image . id_ ) <EOL> self . assertEqual ( member_resp . member_id , member_id ) <EOL> self . assertEqual ( member_resp . schema , Schemas . IMAGE_MEMBER_SCHEMA ) <EOL> self . assertEqual ( member_resp . status , ImageMemberStatus . PENDING ) <EOL> self . assertLessEqual ( delta_in_image_member_updated_time , <NUM_LIT> ) <EOL> response = self . images_client . list_members ( image . id_ ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> get_members_resp = response . entity <EOL> self . assertIsNotNone ( get_members_resp ) <EOL> self . assertEqual ( len ( get_members_resp ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( get_members_resp [ <NUM_LIT:0> ] . created_at , <EOL> member_resp . created_at ) <EOL> self . assertEqual ( get_members_resp [ <NUM_LIT:0> ] . image_id , member_resp . image_id ) <EOL> self . assertEqual ( get_members_resp [ <NUM_LIT:0> ] . member_id , member_resp . member_id ) <EOL> self . assertEqual ( get_members_resp [ <NUM_LIT:0> ] . schema , member_resp . schema ) <EOL> self . assertEqual ( get_members_resp [ <NUM_LIT:0> ] . status , member_resp . status ) <EOL> self . assertEqual ( get_members_resp [ <NUM_LIT:0> ] . updated_at , <EOL> member_resp . updated_at ) <EOL> response = self . alt_images_client . update_member ( <EOL> image . id_ , member_id , ImageMemberStatus . ACCEPTED ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> update_member_resp = response . entity <EOL> self . assertIsNotNone ( update_member_resp ) <EOL> self . assertEqual ( update_member_resp . created_at , member_resp . created_at ) <EOL> self . assertEqual ( update_member_resp . image_id , member_resp . image_id ) <EOL> self . assertEqual ( update_member_resp . member_id , member_resp . member_id ) <EOL> self . assertEqual ( update_member_resp . schema , member_resp . schema ) <EOL> self . assertEqual ( update_member_resp . status , ImageMemberStatus . ACCEPTED ) <EOL> self . assertGreaterEqual ( update_member_resp . updated_at , <EOL> member_resp . updated_at ) <EOL> response = self . images_client . delete_member ( image . id_ , member_id ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> response = self . images_client . list_members ( image . id_ ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> get_members_resp = response . entity <EOL> self . assertListEqual ( get_members_resp , [ ] ) </s>
