<s> """<STR_LIT>""" <EOL> import unittest <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . networking . networks . common . constants import NeutronResponseCodes <EOL> from cloudcafe . networking . networks . common . models . response . network import Network <EOL> from cloudcafe . networking . networks . config import NetworkingSecondUserConfig <EOL> from cloudroast . networking . networks . fixtures import NetworkingAPIFixture <EOL> class NetworkCreateTest ( NetworkingAPIFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( NetworkCreateTest , cls ) . setUpClass ( ) <EOL> cls . network_data = dict ( <EOL> status = '<STR_LIT>' , subnets = [ ] , <EOL> name = '<STR_LIT>' , admin_state_up = None , <EOL> tenant_id = cls . net . networking_auth_composite ( ) . tenant_id , <EOL> shared = False ) <EOL> @ tags ( type = '<STR_LIT>' , rbac = '<STR_LIT>' ) <EOL> def test_network_create ( self ) : <EOL> """<STR_LIT>""" <EOL> expected_network = Network ( ** self . network_data ) <EOL> resp = self . networks . behaviors . create_network ( <EOL> name = expected_network . name , use_exact_name = True , <EOL> raise_exception = False ) <EOL> if resp . response . entity and hasattr ( resp . response . entity , '<STR_LIT:id>' ) : <EOL> self . delete_networks . append ( resp . response . entity . id ) <EOL> self . assertFalse ( resp . failures ) <EOL> network = resp . response . entity <EOL> self . assertNetworkResponse ( expected_network , network ) <EOL> @ tags ( type = '<STR_LIT>' , rbac = '<STR_LIT>' ) <EOL> def test_network_create_w_shared ( self ) : <EOL> """<STR_LIT>""" <EOL> resp = self . networks . behaviors . create_network ( <EOL> shared = True , raise_exception = False ) <EOL> if resp . response . entity and hasattr ( resp . response . entity , '<STR_LIT:id>' ) : <EOL> self . delete_networks . append ( resp . response . entity . id ) <EOL> self . failed_networks . append ( resp . response . entity . id ) <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( <EOL> resp . response . status_code , NeutronResponseCodes . FORBIDDEN ) <EOL> self . assertEqual ( resp . response . status_code , <EOL> NeutronResponseCodes . FORBIDDEN , msg ) <EOL> self . assertIsNone ( resp . response . entity , '<STR_LIT>' ) <EOL> self . assertTrue ( resp . failures , '<STR_LIT>' ) <EOL> @ tags ( type = '<STR_LIT>' , rbac = '<STR_LIT>' ) <EOL> def test_network_create_w_admin_state_up_true ( self ) : <EOL> """<STR_LIT>""" <EOL> expected_network = Network ( ** self . network_data ) <EOL> expected_network . admin_state_up = True <EOL> resp = self . networks . behaviors . create_network ( <EOL> name = expected_network . name , <EOL> admin_state_up = expected_network . admin_state_up , <EOL> use_exact_name = True , raise_exception = False ) <EOL> if resp . response . entity and hasattr ( resp . response . entity , '<STR_LIT:id>' ) : <EOL> self . delete_networks . append ( resp . response . entity . id ) <EOL> self . assertFalse ( resp . failures ) <EOL> network = resp . response . entity <EOL> self . assertNetworkResponse ( expected_network , network ) <EOL> @ tags ( type = '<STR_LIT>' , rbac = '<STR_LIT>' ) <EOL> def test_network_create_w_admin_state_up_false ( self ) : <EOL> """<STR_LIT>""" <EOL> expected_network = Network ( ** self . network_data ) <EOL> expected_network . admin_state_up = False <EOL> resp = self . networks . behaviors . create_network ( <EOL> name = expected_network . name , <EOL> admin_state_up = expected_network . admin_state_up , <EOL> use_exact_name = True , raise_exception = False ) <EOL> if resp . response . entity and hasattr ( resp . response . entity , '<STR_LIT:id>' ) : <EOL> self . delete_networks . append ( resp . response . entity . id ) <EOL> self . assertFalse ( resp . failures ) <EOL> network = resp . response . entity <EOL> self . assertNetworkResponse ( expected_network , network ) <EOL> @ tags ( type = '<STR_LIT>' , rbac = '<STR_LIT>' ) <EOL> def test_network_create_w_tenant_id ( self ) : <EOL> """<STR_LIT>""" <EOL> expected_network = Network ( ** self . network_data ) <EOL> resp = self . networks . behaviors . create_network ( <EOL> name = expected_network . name , <EOL> tenant_id = expected_network . tenant_id , <EOL> use_exact_name = True , raise_exception = False ) <EOL> if resp . response . entity and hasattr ( resp . response . entity , '<STR_LIT:id>' ) : <EOL> self . delete_networks . append ( resp . response . entity . id ) <EOL> self . assertFalse ( resp . failures ) <EOL> network = resp . response . entity <EOL> self . assertNetworkResponse ( expected_network , network ) <EOL> @ unittest . skipIf ( not NetworkingSecondUserConfig ( ) . tenant_id , <EOL> '<STR_LIT>' ) <EOL> @ tags ( type = '<STR_LIT>' , alt_user = '<STR_LIT:yes>' , rbac = '<STR_LIT>' ) <EOL> def test_network_create_w_another_tenant_id ( self ) : <EOL> """<STR_LIT>""" <EOL> resp = self . networks . behaviors . create_network ( <EOL> tenant_id = self . alt_user . tenant_id , raise_exception = False ) <EOL> if resp . response . entity and hasattr ( resp . response . entity , '<STR_LIT:id>' ) : <EOL> self . delete_networks . append ( resp . response . entity . id ) <EOL> self . failed_networks . append ( resp . response . entity . id ) <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( <EOL> resp . response . status_code , NeutronResponseCodes . FORBIDDEN ) <EOL> self . assertEqual ( resp . response . status_code , <EOL> NeutronResponseCodes . FORBIDDEN , msg ) <EOL> self . assertIsNone ( resp . response . entity , '<STR_LIT>' ) <EOL> self . assertTrue ( resp . failures , '<STR_LIT>' ) </s>
