<s> import datetime <EOL> import mock <EOL> import testtools <EOL> from openstack . identity . v2 import extension <EOL> IDENTIFIER = '<STR_LIT>' <EOL> EXAMPLE = { <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT:description>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT:3>' , <EOL> '<STR_LIT:name>' : '<STR_LIT:4>' , <EOL> '<STR_LIT>' : '<STR_LIT:5>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> class TestExtension ( testtools . TestCase ) : <EOL> def test_basic ( self ) : <EOL> sot = extension . Extension ( ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . resource_key ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . resources_key ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . base_path ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . service . service_type ) <EOL> self . assertFalse ( sot . allow_create ) <EOL> self . assertFalse ( sot . allow_retrieve ) <EOL> self . assertFalse ( sot . allow_update ) <EOL> self . assertFalse ( sot . allow_delete ) <EOL> self . assertTrue ( sot . allow_list ) <EOL> def test_make_it ( self ) : <EOL> sot = extension . Extension ( EXAMPLE ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . alias ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT:description>' ] , sot . description ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . links ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT:name>' ] , sot . name ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . namespace ) <EOL> dt = datetime . datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) . replace ( <EOL> tzinfo = None ) <EOL> self . assertEqual ( dt , sot . updated_at . replace ( tzinfo = None ) ) <EOL> def test_list ( self ) : <EOL> resp = mock . Mock ( ) <EOL> resp . body = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT:name>" : "<STR_LIT:a>" } , <EOL> { "<STR_LIT:name>" : "<STR_LIT:b>" } , <EOL> ] <EOL> } <EOL> } <EOL> resp . json = mock . Mock ( return_value = resp . body ) <EOL> session = mock . Mock ( ) <EOL> session . get = mock . Mock ( return_value = resp ) <EOL> sot = extension . Extension ( EXAMPLE ) <EOL> result = sot . list ( session ) <EOL> self . assertEqual ( next ( result ) . name , '<STR_LIT:a>' ) <EOL> self . assertEqual ( next ( result ) . name , '<STR_LIT:b>' ) <EOL> self . assertRaises ( StopIteration , next , result ) </s>
