<s> """<STR_LIT>""" <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . compute . common . exceptions import ItemNotFound <EOL> from cloudcafe . images . common . types import ImageMemberStatus , ImageVisibility <EOL> from cloudroast . images . fixtures import ImagesFixture <EOL> class TestImageVisibility ( ImagesFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TestImageVisibility , cls ) . setUpClass ( ) <EOL> cls . images = cls . images_behavior . create_images_via_task ( count = <NUM_LIT:3> ) <EOL> @ tags ( type = '<STR_LIT>' , regression = '<STR_LIT:true>' ) <EOL> def test_image_visibility_of_images_available_to_user ( self ) : <EOL> """<STR_LIT>""" <EOL> member_id = self . alt_tenant_id <EOL> image = self . images . pop ( ) <EOL> response = self . images_client . add_member ( image . id_ , member_id ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> member = response . entity <EOL> self . images_behavior . validate_image_member ( <EOL> image . id_ , member , member_id ) <EOL> self . assertEqual ( member . status , ImageMemberStatus . PENDING ) <EOL> images = self . alt_images_behavior . list_images_pagination ( ) <EOL> self . assertNotIn ( image , images ) <EOL> images = self . alt_images_behavior . list_images_pagination ( <EOL> visibility = ImageVisibility . SHARED , <EOL> member_status = ImageMemberStatus . ALL ) <EOL> self . assertIn ( image , images ) <EOL> response = self . alt_images_client . update_member ( <EOL> image . id_ , member_id , ImageMemberStatus . REJECTED ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> update_member = response . entity <EOL> self . images_behavior . validate_image_member ( <EOL> image . id_ , update_member , member_id ) <EOL> self . assertEqual ( update_member . status , ImageMemberStatus . REJECTED ) <EOL> images = self . alt_images_behavior . list_images_pagination ( <EOL> visibility = ImageVisibility . SHARED , <EOL> member_status = ImageMemberStatus . ALL ) <EOL> self . assertIn ( image , images ) <EOL> @ tags ( type = '<STR_LIT>' , regression = '<STR_LIT:true>' ) <EOL> def test_image_visibility_of_images_owned_by_particular_user ( self ) : <EOL> """<STR_LIT>""" <EOL> image_one = self . images . pop ( ) <EOL> image_two = self . images . pop ( ) <EOL> with self . assertRaises ( ItemNotFound ) : <EOL> self . alt_images_client . get_image ( image_id = image_one . id_ ) <EOL> with self . assertRaises ( ItemNotFound ) : <EOL> self . alt_images_client . get_image ( image_id = image_two . id_ ) <EOL> images = self . alt_images_behavior . list_images_pagination ( ) <EOL> self . assertNotIn ( image_one , images ) <EOL> self . assertNotIn ( image_two , images ) <EOL> images = self . alt_images_behavior . list_images_pagination ( <EOL> owner = self . tenant_id ) <EOL> self . assertNotIn ( image_one , images ) <EOL> self . assertNotIn ( image_two , images ) <EOL> response = self . images_client . add_member ( <EOL> image_id = image_two . id_ , member_id = self . alt_tenant_id ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> member = response . entity <EOL> self . assertEqual ( member . member_id , self . alt_tenant_id ) <EOL> self . assertEqual ( member . status , ImageMemberStatus . PENDING ) <EOL> response = self . alt_images_client . get_image ( image_id = image_two . id_ ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> image = response . entity <EOL> self . assertEqual ( image , image_two ) <EOL> response = self . alt_images_client . update_member ( <EOL> image_id = image_two . id_ , member_id = self . alt_tenant_id , <EOL> status = ImageMemberStatus . ACCEPTED ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> member = response . entity <EOL> self . assertEqual ( member . member_id , self . alt_tenant_id ) <EOL> self . assertEqual ( member . status , ImageMemberStatus . ACCEPTED ) <EOL> images = self . alt_images_behavior . list_images_pagination ( ) <EOL> self . assertNotIn ( image_one , images ) <EOL> self . assertIn ( image_two , images ) <EOL> images = self . alt_images_behavior . list_images_pagination ( <EOL> owner = self . tenant_id ) <EOL> self . assertNotIn ( image_one , images ) <EOL> self . assertIn ( image_two , images ) </s>
