<s> import uuid <EOL> from openstack . object_store . v1 import container as _container <EOL> from openstack . tests . functional import base <EOL> class TestContainer ( base . BaseFunctionalTest ) : <EOL> NAME = uuid . uuid4 ( ) . hex <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TestContainer , cls ) . setUpClass ( ) <EOL> container = cls . conn . object_store . create_container ( name = cls . NAME ) <EOL> assert isinstance ( container , _container . Container ) <EOL> cls . assertIs ( cls . NAME , container . name ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> result = cls . conn . object_store . delete_container ( cls . NAME , <EOL> ignore_missing = False ) <EOL> cls . assertIs ( None , result ) <EOL> def test_list ( self ) : <EOL> names = [ o . name for o in self . conn . object_store . containers ( ) ] <EOL> self . assertIn ( self . NAME , names ) <EOL> def test_system_metadata ( self ) : <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertEqual ( <NUM_LIT:0> , container . object_count ) <EOL> self . assertEqual ( <NUM_LIT:0> , container . bytes_used ) <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertIsNone ( container . read_ACL ) <EOL> self . assertIsNone ( container . write_ACL ) <EOL> self . conn . object_store . set_container_metadata ( <EOL> container , read_ACL = '<STR_LIT>' , write_ACL = '<STR_LIT>' ) <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertEqual ( '<STR_LIT>' , container . read_ACL ) <EOL> self . assertEqual ( '<STR_LIT>' , container . write_ACL ) <EOL> self . conn . object_store . set_container_metadata ( <EOL> container , read_ACL = '<STR_LIT>' ) <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertEqual ( '<STR_LIT>' , container . read_ACL ) <EOL> self . assertEqual ( '<STR_LIT>' , container . write_ACL ) <EOL> self . conn . object_store . set_container_metadata ( <EOL> container , k0 = '<STR_LIT>' , sync_key = '<STR_LIT>' ) <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertTrue ( container . metadata ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , container . read_ACL ) <EOL> self . assertEqual ( '<STR_LIT>' , container . write_ACL ) <EOL> self . assertEqual ( '<STR_LIT>' , container . sync_key ) <EOL> self . conn . object_store . delete_container_metadata ( container , <EOL> [ '<STR_LIT>' ] ) <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertTrue ( container . metadata ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , container . read_ACL ) <EOL> self . assertEqual ( '<STR_LIT>' , container . write_ACL ) <EOL> self . assertIsNone ( container . sync_key ) <EOL> def test_custom_metadata ( self ) : <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertFalse ( container . metadata ) <EOL> self . conn . object_store . set_container_metadata ( container ) <EOL> container = self . conn . object_store . get_container_metadata ( container ) <EOL> self . assertFalse ( container . metadata ) <EOL> self . conn . object_store . set_container_metadata ( container , k0 = '<STR_LIT>' ) <EOL> container = self . conn . object_store . get_container_metadata ( container ) <EOL> self . assertFalse ( container . metadata ) <EOL> self . conn . object_store . set_container_metadata ( container , k1 = '<STR_LIT>' ) <EOL> container = self . conn . object_store . get_container_metadata ( container ) <EOL> self . assertTrue ( container . metadata ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( container . metadata ) ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) <EOL> self . conn . object_store . set_container_metadata ( self . NAME , k2 = '<STR_LIT>' ) <EOL> container = self . conn . object_store . get_container_metadata ( container ) <EOL> self . assertTrue ( container . metadata ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( container . metadata ) ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) <EOL> self . conn . object_store . set_container_metadata ( container , k1 = '<STR_LIT>' ) <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertTrue ( container . metadata ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( container . metadata ) ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) <EOL> self . conn . object_store . delete_container_metadata ( container , [ '<STR_LIT>' ] ) <EOL> container = self . conn . object_store . get_container_metadata ( self . NAME ) <EOL> self . assertTrue ( container . metadata ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( container . metadata ) ) <EOL> self . assertIn ( '<STR_LIT>' , container . metadata ) <EOL> self . assertEqual ( '<STR_LIT>' , container . metadata [ '<STR_LIT>' ] ) </s>
