<s> from tempest import test <EOL> from neutron . tests . tempest . api import base <EOL> from neutron . tests . tempest import config <EOL> CONF = config . CONF <EOL> class NetworksTestJSON ( base . BaseNetworkTest ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def resource_setup ( cls ) : <EOL> super ( NetworksTestJSON , cls ) . resource_setup ( ) <EOL> cls . network = cls . create_network ( ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_show_network ( self ) : <EOL> body = self . client . show_network ( self . network [ '<STR_LIT:id>' ] ) <EOL> network = body [ '<STR_LIT>' ] <EOL> fields = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> if test . is_extension_enabled ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> fields . append ( '<STR_LIT>' ) <EOL> for key in fields : <EOL> self . assertEqual ( network [ key ] , self . network [ key ] ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_show_network_fields ( self ) : <EOL> fields = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> if test . is_extension_enabled ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> fields . append ( '<STR_LIT>' ) <EOL> body = self . client . show_network ( self . network [ '<STR_LIT:id>' ] , <EOL> fields = fields ) <EOL> network = body [ '<STR_LIT>' ] <EOL> self . assertEqual ( sorted ( network . keys ( ) ) , sorted ( fields ) ) <EOL> for field_name in fields : <EOL> self . assertEqual ( network [ field_name ] , self . network [ field_name ] ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> @ test . requires_ext ( extension = "<STR_LIT>" , <EOL> service = "<STR_LIT>" ) <EOL> def test_create_update_network_description ( self ) : <EOL> body = self . create_network ( description = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , body [ '<STR_LIT:description>' ] ) <EOL> net_id = body [ '<STR_LIT:id>' ] <EOL> body = self . client . list_networks ( id = net_id ) [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( '<STR_LIT>' , body [ '<STR_LIT:description>' ] ) <EOL> body = self . client . update_network ( body [ '<STR_LIT:id>' ] , <EOL> description = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , body [ '<STR_LIT>' ] [ '<STR_LIT:description>' ] ) <EOL> body = self . client . list_networks ( id = net_id ) [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( '<STR_LIT>' , body [ '<STR_LIT:description>' ] ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_list_networks_fields ( self ) : <EOL> fields = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> if test . is_extension_enabled ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> fields . append ( '<STR_LIT>' ) <EOL> body = self . client . list_networks ( fields = fields ) <EOL> networks = body [ '<STR_LIT>' ] <EOL> self . assertNotEmpty ( networks , "<STR_LIT>" ) <EOL> for network in networks : <EOL> self . assertEqual ( sorted ( network . keys ( ) ) , sorted ( fields ) ) </s>
