<s> """<STR_LIT>""" <EOL> import unittest <EOL> import copy <EOL> from optparse import OptionParser <EOL> from xml . etree import ElementTree as ET <EOL> from lib import naming <EOL> from lib import policy <EOL> from lib import nsxv <EOL> import nsxv_mocktest <EOL> class NsxvFunctionalTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> _parser = OptionParser ( ) <EOL> _parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , default = '<STR_LIT>' ) <EOL> ( FLAGS , args ) = _parser . parse_args ( ) <EOL> self . defs = naming . Naming ( FLAGS . definitions ) <EOL> def tearDown ( self ) : <EOL> pass <EOL> def runTest ( self ) : <EOL> pass <EOL> def test_nsxv_policy ( self ) : <EOL> pol = policy . ParsePolicy ( nsxv_mocktest . POLICY , self . defs ) <EOL> exp_info = <NUM_LIT:2> <EOL> nsx = copy . deepcopy ( pol ) <EOL> fw = nsxv . Nsxv ( nsx , exp_info ) <EOL> output = str ( fw ) <EOL> root = ET . fromstring ( output ) <EOL> section_name = { '<STR_LIT:id>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' } <EOL> self . assertEqual ( root . attrib , section_name ) <EOL> self . assertEqual ( root . find ( '<STR_LIT>' ) . text , '<STR_LIT>' ) <EOL> self . assertEqual ( root . find ( '<STR_LIT>' ) . text , '<STR_LIT>' ) <EOL> exp_destaddr = [ '<STR_LIT>' ] <EOL> for destination in root . findall ( '<STR_LIT>' ) : <EOL> self . assertEqual ( ( destination . find ( '<STR_LIT:type>' ) . text ) , '<STR_LIT>' ) <EOL> value = ( destination . find ( '<STR_LIT:value>' ) . text ) <EOL> if value not in exp_destaddr : <EOL> self . fail ( '<STR_LIT>' ) <EOL> protocol = int ( root . find ( '<STR_LIT>' ) . text ) <EOL> self . assertEqual ( protocol , <NUM_LIT:6> ) <EOL> destination_port = root . find ( '<STR_LIT>' ) . text <EOL> self . assertEqual ( destination_port , '<STR_LIT>' ) <EOL> def test_nsxv_nosectiondid ( self ) : <EOL> pol = policy . ParsePolicy ( nsxv_mocktest . POLICY_NO_SECTION_ID , self . defs ) <EOL> exp_info = <NUM_LIT:2> <EOL> nsx = copy . deepcopy ( pol ) <EOL> fw = nsxv . Nsxv ( nsx , exp_info ) <EOL> output = str ( fw ) <EOL> root = ET . fromstring ( output ) <EOL> section_name = { '<STR_LIT:name>' : '<STR_LIT>' } <EOL> self . assertEqual ( root . attrib , section_name ) <EOL> self . assertEqual ( root . find ( '<STR_LIT>' ) . text , '<STR_LIT>' ) <EOL> self . assertEqual ( root . find ( '<STR_LIT>' ) . text , '<STR_LIT>' ) <EOL> protocol = int ( root . find ( '<STR_LIT>' ) . text ) <EOL> self . assertEqual ( protocol , <NUM_LIT:1> ) <EOL> def test_nsxv_nofiltertype ( self ) : <EOL> def test_nofiltertype ( ) : <EOL> pol = policy . ParsePolicy ( nsxv_mocktest . POLICY_NO_FILTERTYPE , self . defs ) <EOL> exp_info = <NUM_LIT:2> <EOL> nsx = copy . deepcopy ( pol ) <EOL> fw = nsxv . Nsxv ( nsx , exp_info ) <EOL> self . assertRaises ( nsxv . UnsupportedNsxvAccessListError , test_nofiltertype ) <EOL> def test_nsxv_incorrectfiltertype ( self ) : <EOL> def test_incorrectfiltertype ( ) : <EOL> pol = policy . ParsePolicy ( nsxv_mocktest . POLICY_INCORRECT_FILTERTYPE , self . defs ) <EOL> exp_info = <NUM_LIT:2> <EOL> nsx = copy . deepcopy ( pol ) <EOL> fw = nsxv . Nsxv ( nsx , exp_info ) <EOL> self . assertRaises ( nsxv . UnsupportedNsxvAccessListError , test_incorrectfiltertype ) <EOL> def test_nsxv_optionkywd ( self ) : <EOL> def test_optionkywd ( ) : <EOL> pol = policy . ParsePolicy ( nsxv_mocktest . POLICY_OPTION_KYWD , self . defs ) <EOL> exp_info = <NUM_LIT:2> <EOL> nsx = copy . deepcopy ( pol ) <EOL> fw = nsxv . Nsxv ( nsx , exp_info ) <EOL> output = str ( fw ) <EOL> self . assertRaises ( nsxv . NsxvAclTermError , test_optionkywd ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
