<s> from neutron_lib import constants <EOL> from neutron . extensions import portbindings <EOL> from neutron . plugins . ml2 . drivers . macvtap . mech_driver import mech_macvtap <EOL> from neutron . tests . unit . plugins . ml2 import _test_mech_agent as base <EOL> class MacvtapMechanismBaseTestCase ( base . AgentMechanismBaseTestCase ) : <EOL> VIF_TYPE = portbindings . VIF_TYPE_MACVTAP <EOL> CAP_PORT_FILTER = False <EOL> AGENT_TYPE = constants . AGENT_TYPE_MACVTAP <EOL> GOOD_MAPPINGS = { '<STR_LIT>' : '<STR_LIT>' } <EOL> GOOD_CONFIGS = { '<STR_LIT>' : GOOD_MAPPINGS } <EOL> BAD_MAPPINGS = { '<STR_LIT>' : '<STR_LIT>' } <EOL> BAD_CONFIGS = { '<STR_LIT>' : BAD_MAPPINGS } <EOL> AGENTS = [ { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : GOOD_CONFIGS , <EOL> '<STR_LIT:host>' : '<STR_LIT:host>' } ] <EOL> AGENTS_DEAD = [ { '<STR_LIT>' : False , <EOL> '<STR_LIT>' : GOOD_CONFIGS , <EOL> '<STR_LIT:host>' : '<STR_LIT>' } ] <EOL> AGENTS_BAD = [ { '<STR_LIT>' : False , <EOL> '<STR_LIT>' : GOOD_CONFIGS , <EOL> '<STR_LIT:host>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : BAD_CONFIGS , <EOL> '<STR_LIT:host>' : '<STR_LIT>' } ] <EOL> def setUp ( self ) : <EOL> super ( MacvtapMechanismBaseTestCase , self ) . setUp ( ) <EOL> self . driver = mech_macvtap . MacvtapMechanismDriver ( ) <EOL> self . driver . initialize ( ) <EOL> class MacvtapMechanismGenericTestCase ( MacvtapMechanismBaseTestCase , <EOL> base . AgentMechanismGenericTestCase ) : <EOL> pass <EOL> class MacvtapMechanismFlatTestCase ( MacvtapMechanismBaseTestCase , <EOL> base . AgentMechanismFlatTestCase ) : <EOL> def test_type_flat_vif_details ( self ) : <EOL> context = base . FakePortContext ( self . AGENT_TYPE , <EOL> self . AGENTS , <EOL> self . FLAT_SEGMENTS , <EOL> vnic_type = self . VNIC_TYPE ) <EOL> self . driver . bind_port ( context ) <EOL> vif_details = context . _bound_vif_details <EOL> self . assertIsNone ( vif_details . get ( portbindings . VIF_DETAILS_VLAN ) ) <EOL> self . assertEqual ( "<STR_LIT>" , vif_details . get ( <EOL> portbindings . VIF_DETAILS_MACVTAP_MODE ) ) <EOL> self . assertEqual ( "<STR_LIT>" , vif_details . get ( <EOL> portbindings . VIF_DETAILS_PHYSICAL_INTERFACE ) ) <EOL> self . assertEqual ( "<STR_LIT>" , vif_details . get ( <EOL> portbindings . VIF_DETAILS_MACVTAP_SOURCE ) ) <EOL> class MacvtapMechanismVlanTestCase ( MacvtapMechanismBaseTestCase , <EOL> base . AgentMechanismVlanTestCase ) : <EOL> def test_type_vlan_vif_details ( self ) : <EOL> context = base . FakePortContext ( self . AGENT_TYPE , <EOL> self . AGENTS , <EOL> self . VLAN_SEGMENTS , <EOL> vnic_type = self . VNIC_TYPE ) <EOL> self . driver . bind_port ( context ) <EOL> vif_details = context . _bound_vif_details <EOL> self . assertEqual ( <NUM_LIT> , vif_details . get ( portbindings . VIF_DETAILS_VLAN ) ) <EOL> self . assertEqual ( "<STR_LIT>" , vif_details . get ( <EOL> portbindings . VIF_DETAILS_MACVTAP_MODE ) ) <EOL> self . assertEqual ( "<STR_LIT>" , vif_details . get ( <EOL> portbindings . VIF_DETAILS_PHYSICAL_INTERFACE ) ) <EOL> self . assertEqual ( "<STR_LIT>" , vif_details . get ( <EOL> portbindings . VIF_DETAILS_MACVTAP_SOURCE ) ) </s>
