<s> '''<STR_LIT>''' <EOL> import os <EOL> import sys <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( os . path . dirname ( __file__ ) + '<STR_LIT:/>' + '<STR_LIT>' ) ) <EOL> import unittest <EOL> import shutil <EOL> from flexmock import flexmock <EOL> from jnpr . openclos . l3Clos import L3ClosMediation <EOL> from jnpr . openclos . model import Pod , Device , InterfaceLogical , InterfaceDefinition , TrapGroup <EOL> from test_dao import InMemoryDao <EOL> from jnpr . openclos . exception import PodNotFound <EOL> def getPodDict ( ) : <EOL> return { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:3> , "<STR_LIT>" : [ { "<STR_LIT>" : "<STR_LIT>" } ] , <EOL> "<STR_LIT>" : <NUM_LIT:100> , "<STR_LIT>" : <NUM_LIT:2> , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:200> , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : "<STR_LIT>" } <EOL> class TestL3Clos ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . _conf = { } <EOL> self . _conf [ '<STR_LIT>' ] = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , '<STR_LIT>' ) <EOL> self . _conf [ '<STR_LIT>' ] = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } <EOL> } <EOL> self . _dao = InMemoryDao . getInstance ( ) <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> def tearDown ( self ) : <EOL> '''<STR_LIT>''' <EOL> shutil . rmtree ( self . _conf [ '<STR_LIT>' ] , ignore_errors = True ) <EOL> InMemoryDao . _destroy ( ) <EOL> self . l3ClosMediation = None <EOL> def testLoadClosDefinition ( self ) : <EOL> pods = self . l3ClosMediation . loadClosDefinition ( ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( pods ) ) <EOL> def testLoadNonExistingClosDefinition ( self ) : <EOL> pods = self . l3ClosMediation . loadClosDefinition ( '<STR_LIT>' ) <EOL> self . assertIsNone ( pods ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:0> , len ( self . _dao . getAll ( session , Pod ) ) ) <EOL> def testCreatePod ( self ) : <EOL> podDict = getPodDict ( ) <EOL> self . l3ClosMediation . createPod ( '<STR_LIT>' , podDict ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:1> , session . query ( Pod ) . count ( ) ) <EOL> def testUpdatePod ( self ) : <EOL> podDict = getPodDict ( ) <EOL> pod = self . l3ClosMediation . createPod ( '<STR_LIT>' , podDict ) <EOL> inventoryDict = { <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } , <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } , <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } , <EOL> { "<STR_LIT:name>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> ] <EOL> } <EOL> self . l3ClosMediation . updatePod ( pod . id , podDict , inventoryDict ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> pod = session . query ( Pod ) . one ( ) <EOL> self . assertEqual ( <NUM_LIT:5> , len ( pod . devices ) ) <EOL> deployCount = <NUM_LIT:0> <EOL> for device in pod . devices : <EOL> if device . deployStatus == "<STR_LIT>" : <EOL> deployCount += <NUM_LIT:1> <EOL> self . assertEqual ( <NUM_LIT:2> , deployCount ) <EOL> def testUpdatePodInvalidId ( self ) : <EOL> with self . assertRaises ( PodNotFound ) as ve : <EOL> self . l3ClosMediation . updatePod ( "<STR_LIT>" , None ) <EOL> def createPodSpineLeaf ( self ) : <EOL> podDict = getPodDict ( ) <EOL> pod = self . l3ClosMediation . createPod ( '<STR_LIT>' , podDict ) <EOL> return pod <EOL> def testCablingPlanAndDeviceConfig ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> pod = self . createPodSpineLeaf ( ) <EOL> self . assertEqual ( True , self . l3ClosMediation . createCablingPlan ( pod . id ) ) <EOL> self . assertEqual ( True , self . l3ClosMediation . createDeviceConfig ( pod . id ) ) <EOL> def testCreateLinks ( self ) : <EOL> pod = self . createPodSpineLeaf ( ) <EOL> podId = pod . id <EOL> with self . _dao . getReadSession ( ) as session : <EOL> spine01Port0 = session . query ( InterfaceDefinition ) . join ( Device ) . filter ( InterfaceDefinition . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == podId ) . one ( ) <EOL> self . assertIsNotNone ( spine01Port0 . peer ) <EOL> self . assertEqual ( '<STR_LIT>' , spine01Port0 . peer . name ) <EOL> self . assertEqual ( '<STR_LIT>' , spine01Port0 . peer . device . name ) <EOL> spine02Port0 = session . query ( InterfaceDefinition ) . join ( Device ) . filter ( InterfaceDefinition . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == podId ) . one ( ) <EOL> self . assertIsNotNone ( spine02Port0 . peer ) <EOL> self . assertEqual ( '<STR_LIT>' , spine02Port0 . peer . name ) <EOL> self . assertEqual ( '<STR_LIT>' , spine02Port0 . peer . device . name ) <EOL> spine01Port1 = session . query ( InterfaceDefinition ) . join ( Device ) . filter ( InterfaceDefinition . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == podId ) . one ( ) <EOL> self . assertIsNotNone ( spine01Port1 . peer ) <EOL> self . assertEqual ( '<STR_LIT>' , spine01Port1 . peer . name ) <EOL> self . assertEqual ( '<STR_LIT>' , spine01Port1 . peer . device . name ) <EOL> spine02Port1 = session . query ( InterfaceDefinition ) . join ( Device ) . filter ( InterfaceDefinition . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == podId ) . one ( ) <EOL> self . assertIsNotNone ( spine02Port1 . peer ) <EOL> self . assertEqual ( '<STR_LIT>' , spine02Port1 . peer . name ) <EOL> self . assertEqual ( '<STR_LIT>' , spine02Port1 . peer . device . name ) <EOL> spine01Port2 = session . query ( InterfaceDefinition ) . join ( Device ) . filter ( InterfaceDefinition . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == podId ) . one ( ) <EOL> self . assertIsNotNone ( spine01Port2 . peer ) <EOL> self . assertEqual ( '<STR_LIT>' , spine01Port2 . peer . name ) <EOL> self . assertEqual ( '<STR_LIT>' , spine01Port2 . peer . device . name ) <EOL> spine02Port2 = session . query ( InterfaceDefinition ) . join ( Device ) . filter ( InterfaceDefinition . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == podId ) . one ( ) <EOL> self . assertIsNotNone ( spine02Port2 . peer ) <EOL> self . assertEqual ( '<STR_LIT>' , spine02Port2 . peer . name ) <EOL> self . assertEqual ( '<STR_LIT>' , spine02Port2 . peer . device . name ) <EOL> def testCreateLeafAndIfds ( self ) : <EOL> with self . _dao . getReadSession ( ) as session : <EOL> from test_model import createPod <EOL> pod = createPod ( '<STR_LIT:test>' , session ) <EOL> pod . spineCount = <NUM_LIT:6> <EOL> leaves = [ { "<STR_LIT:name>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] <EOL> self . l3ClosMediation . _createLeafAndIfds ( session , pod , leaves ) <EOL> interfaces = session . query ( InterfaceDefinition ) . all ( ) <EOL> self . assertEqual ( <NUM_LIT:6> , len ( interfaces ) ) <EOL> def testGetLeafSpineFromPod ( self ) : <EOL> self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> pod = session . query ( Pod ) . one ( ) <EOL> leafSpineDict = self . l3ClosMediation . _getLeafSpineFromPod ( pod ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( leafSpineDict [ '<STR_LIT>' ] ) ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( leafSpineDict [ '<STR_LIT>' ] ) ) <EOL> def testAllocateLoopback ( self ) : <EOL> pod = self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> ifl = session . query ( InterfaceLogical ) . join ( Device ) . filter ( InterfaceLogical . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == pod . id ) . one ( ) <EOL> self . assertEqual ( '<STR_LIT>' , ifl . ipaddress ) <EOL> ifl = session . query ( InterfaceLogical ) . join ( Device ) . filter ( InterfaceLogical . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == pod . id ) . one ( ) <EOL> self . assertEqual ( '<STR_LIT>' , ifl . ipaddress ) <EOL> self . assertEqual ( '<STR_LIT>' , pod . allocatedLoopbackBlock ) <EOL> self . assertEqual ( <NUM_LIT:5> , session . query ( InterfaceLogical ) . join ( Device ) . filter ( InterfaceLogical . name == '<STR_LIT>' ) . filter ( Device . pod_id == pod . id ) . count ( ) ) <EOL> def testAllocateIrb ( self ) : <EOL> pod = self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( '<STR_LIT>' , pod . allocatedIrbBlock ) <EOL> ifl = session . query ( InterfaceLogical ) . join ( Device ) . filter ( InterfaceLogical . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == pod . id ) . one ( ) <EOL> self . assertEqual ( '<STR_LIT>' , ifl . ipaddress ) <EOL> ifl = session . query ( InterfaceLogical ) . join ( Device ) . filter ( InterfaceLogical . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == pod . id ) . one ( ) <EOL> self . assertEqual ( '<STR_LIT>' , ifl . ipaddress ) <EOL> def testAllocateInterconnect ( self ) : <EOL> pod = self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> ifl = session . query ( InterfaceLogical ) . join ( Device ) . filter ( InterfaceLogical . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == pod . id ) . one ( ) <EOL> belowIfd = session . query ( InterfaceDefinition ) . filter ( InterfaceDefinition . id == ifl . layer_below_id ) . one ( ) <EOL> self . assertEqual ( '<STR_LIT>' , belowIfd . name ) <EOL> self . assertEqual ( '<STR_LIT>' , ifl . ipaddress ) <EOL> ifl = session . query ( InterfaceLogical ) . join ( Device ) . filter ( InterfaceLogical . name == '<STR_LIT>' ) . filter ( Device . name == '<STR_LIT>' ) . filter ( Device . pod_id == pod . id ) . one ( ) <EOL> belowIfd = session . query ( InterfaceDefinition ) . filter ( InterfaceDefinition . id == ifl . layer_below_id ) . one ( ) <EOL> self . assertEqual ( '<STR_LIT>' , belowIfd . name ) <EOL> self . assertEqual ( '<STR_LIT>' , ifl . ipaddress ) <EOL> def testAllocateAsNumber ( self ) : <EOL> self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:100> , session . query ( Device ) . filter ( Device . role == '<STR_LIT>' ) . all ( ) [ <NUM_LIT:0> ] . asn ) <EOL> self . assertEqual ( <NUM_LIT> , session . query ( Device ) . filter ( Device . role == '<STR_LIT>' ) . all ( ) [ <NUM_LIT:1> ] . asn ) <EOL> def testCreatePolicyOptionSpine ( self ) : <EOL> self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> pod = session . query ( Pod ) . one ( ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , pod ) <EOL> device . pod . allocatedIrbBlock = '<STR_LIT>' <EOL> device . pod . allocatedLoopbackBlock = '<STR_LIT>' <EOL> configlet = self . l3ClosMediation . _createPolicyOption ( session , device ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet and '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet and '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet ) <EOL> def testCreatePolicyOptionLeaf ( self ) : <EOL> self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> pod = session . query ( Pod ) . one ( ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , pod ) <EOL> device . pod . allocatedIrbBlock = '<STR_LIT>' <EOL> device . pod . allocatedLoopbackBlock = '<STR_LIT>' <EOL> mockSession = flexmock ( session ) <EOL> mockSession . should_receive ( '<STR_LIT>' ) . and_return ( InterfaceLogical ( "<STR_LIT:test>" , device , '<STR_LIT>' ) ) <EOL> configlet = self . l3ClosMediation . _createPolicyOption ( session , device ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet and '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet and '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet and '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' not in configlet ) <EOL> def testInitWithTemplate ( self ) : <EOL> from jinja2 import TemplateNotFound <EOL> self . assertIsNotNone ( self . l3ClosMediation . _templateEnv . get_template ( '<STR_LIT>' ) ) <EOL> with self . assertRaises ( TemplateNotFound ) as e : <EOL> self . l3ClosMediation . _templateEnv . get_template ( '<STR_LIT>' ) <EOL> self . assertTrue ( '<STR_LIT>' in e . exception . message ) <EOL> def createTrapGroupsInDb ( self , dao ) : <EOL> newtargets = [ ] <EOL> for newtarget in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> newtargets . append ( TrapGroup ( '<STR_LIT>' , newtarget , int ( '<STR_LIT>' ) ) ) <EOL> newtargets . append ( TrapGroup ( '<STR_LIT>' , newtarget , <NUM_LIT> ) ) <EOL> with self . _dao . getReadWriteSession ( ) as session : <EOL> self . _dao . createObjects ( session , newtargets ) <EOL> def testGetOpenClosTrapGroupSettingsNoStagedZtp ( self ) : <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:0> , len ( self . l3ClosMediation . _getOpenclosTrapGroupSettings ( session ) ) ) <EOL> def testGetOpenClosTrapGroupSettingsWithStagedZtp ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : True } <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT:port>' : <NUM_LIT> , '<STR_LIT:target>' : '<STR_LIT>' } } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:1> , len ( self . l3ClosMediation . _getOpenclosTrapGroupSettings ( session ) ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( self . l3ClosMediation . _getOpenclosTrapGroupSettings ( session ) [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) ) <EOL> self . assertEqual ( '<STR_LIT>' , self . l3ClosMediation . _getOpenclosTrapGroupSettings ( session ) [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> self . createTrapGroupsInDb ( self . _dao ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:1> , len ( self . l3ClosMediation . _getOpenclosTrapGroupSettings ( session ) ) ) <EOL> self . assertEqual ( <NUM_LIT> , self . l3ClosMediation . _getOpenclosTrapGroupSettings ( session ) [ <NUM_LIT:0> ] [ '<STR_LIT:port>' ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( self . l3ClosMediation . _getOpenclosTrapGroupSettings ( session ) [ <NUM_LIT:0> ] [ '<STR_LIT>' ] ) ) <EOL> def testCreateSnmpTrapAndEventSpine ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT:port>' : <NUM_LIT> , '<STR_LIT:target>' : '<STR_LIT>' } } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> self . createTrapGroupsInDb ( self . _dao ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> configlet = self . l3ClosMediation . _createSnmpTrapAndEvent ( session , device ) <EOL> self . assertEqual ( '<STR_LIT>' , configlet ) <EOL> def testCreateSnmpTrapAndEventLeafNoStagedZtp ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT:port>' : <NUM_LIT> , '<STR_LIT:target>' : '<STR_LIT>' } } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> self . createTrapGroupsInDb ( self . _dao ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> configlet = self . l3ClosMediation . _createSnmpTrapAndEvent ( session , device ) <EOL> self . assertEqual ( '<STR_LIT>' , configlet ) <EOL> def testCreateSnmpTrapAndEventLeafWith2ndStageZtp ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : True } <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT:port>' : <NUM_LIT> , '<STR_LIT:target>' : '<STR_LIT>' } } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> self . createTrapGroupsInDb ( self . _dao ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> configlet = self . l3ClosMediation . _createSnmpTrapAndEvent ( session , device ) <EOL> self . assertTrue ( '<STR_LIT>' == configlet ) <EOL> def testCreateRoutingOptionsStatic ( self ) : <EOL> self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> pod = session . query ( Pod ) . one ( ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , pod ) <EOL> device . pod . outOfBandGateway = '<STR_LIT>' <EOL> device . pod . outOfBandAddressList = '<STR_LIT>' <EOL> configlet = self . l3ClosMediation . _createRoutingOptionsStatic ( session , device ) <EOL> self . assertEquals ( <NUM_LIT:1> , configlet . count ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( <NUM_LIT:2> , configlet . count ( '<STR_LIT>' ) ) <EOL> def testCreateAccessInterface ( self ) : <EOL> with self . _dao . getReadSession ( ) as session : <EOL> from test_model import createPod <EOL> pod = createPod ( '<STR_LIT:test>' , session ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , pod ) <EOL> configlet = self . l3ClosMediation . _createAccessPortInterfaces ( session , device ) <EOL> self . assertEquals ( <NUM_LIT> , configlet . count ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' in configlet ) <EOL> def testCreateAccessInterfaceEx4300 ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] [ '<STR_LIT>' ] = { <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : '<STR_LIT>' <EOL> } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> from test_model import createPod <EOL> pod = createPod ( '<STR_LIT:test>' , session ) <EOL> device = Device ( "<STR_LIT:test>" , "<STR_LIT>" , "<STR_LIT:user>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , pod ) <EOL> configlet = self . l3ClosMediation . _createAccessPortInterfaces ( session , device ) <EOL> self . assertEquals ( <NUM_LIT> , configlet . count ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( '<STR_LIT>' in configlet ) <EOL> self . assertTrue ( '<STR_LIT>' in configlet ) <EOL> def testCreateLeafGenericConfig ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT:port>' : <NUM_LIT> , '<STR_LIT:target>' : '<STR_LIT>' } } <EOL> self . _conf [ '<STR_LIT>' ] [ '<STR_LIT>' ] = { "<STR_LIT>" : '<STR_LIT>' , "<STR_LIT>" : '<STR_LIT>' } <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : True } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> self . createPodSpineLeaf ( ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> pod = session . query ( Pod ) . one ( ) <EOL> pod . outOfBandGateway = '<STR_LIT>' <EOL> pod . outOfBandAddressList = '<STR_LIT>' <EOL> leafSettings = self . l3ClosMediation . _createLeafGenericConfigsFor2Stage ( session , pod ) <EOL> self . assertTrue ( <NUM_LIT:1> , len ( leafSettings ) ) <EOL> configlet = leafSettings [ <NUM_LIT:0> ] . config <EOL> self . assertTrue ( '<STR_LIT>' != configlet ) <EOL> self . assertTrue ( '<STR_LIT>' in configlet ) <EOL> self . assertEquals ( <NUM_LIT:1> , configlet . count ( '<STR_LIT>' ) ) <EOL> self . assertEquals ( <NUM_LIT:2> , configlet . count ( '<STR_LIT>' ) ) <EOL> def testGetSnmpTrapTargets ( self ) : <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:0> , len ( self . l3ClosMediation . _getSnmpTrapTargets ( session ) ) ) <EOL> def testGetSnmpTrapTargetsWithStagedZtp ( self ) : <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT:port>' : <NUM_LIT> , '<STR_LIT:target>' : '<STR_LIT>' } } <EOL> self . _conf [ '<STR_LIT>' ] = { '<STR_LIT>' : True } <EOL> self . l3ClosMediation = L3ClosMediation ( self . _conf , InMemoryDao ) <EOL> with self . _dao . getReadSession ( ) as session : <EOL> self . assertEqual ( <NUM_LIT:1> , len ( self . l3ClosMediation . _getSnmpTrapTargets ( session ) ) ) <EOL> self . assertEqual ( '<STR_LIT>' , self . l3ClosMediation . _getSnmpTrapTargets ( session ) [ <NUM_LIT:0> ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
