<s> import mock <EOL> import unittest <EOL> from networking_cisco . plugins . cisco . cpnr . netns import iflist <EOL> from networking_cisco . plugins . cisco . cpnr . netns import nslist <EOL> class TestNetNs ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_nslist ( self , mock_listdir , mock_path ) : <EOL> mock_path . exists . return_value = True <EOL> mock_listdir . return_value = [ ] <EOL> mock_listdir . return_value . append ( ( '<STR_LIT>' ) ) <EOL> mock_listdir . return_value . append ( ( '<STR_LIT>' ) ) <EOL> nsdirs = nslist ( ) <EOL> self . assertEqual ( '<STR_LIT>' , nsdirs [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( '<STR_LIT>' , nsdirs [ <NUM_LIT:1> ] ) <EOL> mock_path . exists . return_value = False <EOL> nsdirs = nslist ( ) <EOL> self . assertEqual ( [ ] , nsdirs ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_iflist ( self , mock_check_output ) : <EOL> ip_addr_str = ( <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' <EOL> b'<STR_LIT>' ) <EOL> mock_check_output . return_value = ip_addr_str <EOL> interfaces = iflist ( ) <EOL> name , addr , mask = interfaces [ <NUM_LIT:0> ] <EOL> self . assertEqual ( b'<STR_LIT>' , name ) <EOL> self . assertEqual ( b'<STR_LIT:127.0.0.1>' , addr ) <EOL> self . assertEqual ( b'<STR_LIT>' , mask ) <EOL> name , addr , mask = interfaces [ <NUM_LIT:1> ] <EOL> self . assertEqual ( b'<STR_LIT>' , name ) <EOL> self . assertEqual ( b'<STR_LIT>' , addr ) <EOL> self . assertEqual ( b'<STR_LIT>' , mask ) <EOL> interfaces = iflist ( ignore = ( b"<STR_LIT>" , ) ) <EOL> name , addr , mask = interfaces [ <NUM_LIT:0> ] <EOL> self . assertEqual ( b'<STR_LIT>' , name ) <EOL> self . assertEqual ( b'<STR_LIT>' , addr ) <EOL> self . assertEqual ( b'<STR_LIT>' , mask ) <EOL> with self . assertRaises ( IndexError ) : <EOL> name , addr , mask = interfaces [ <NUM_LIT:1> ] <EOL> interfaces = iflist ( ignore = ( b"<STR_LIT>" , ) ) <EOL> name , addr , mask = interfaces [ <NUM_LIT:0> ] <EOL> self . assertEqual ( b'<STR_LIT>' , name ) <EOL> self . assertEqual ( b'<STR_LIT:127.0.0.1>' , addr ) <EOL> self . assertEqual ( b'<STR_LIT>' , mask ) <EOL> with self . assertRaises ( IndexError ) : <EOL> name , addr , mask = interfaces [ <NUM_LIT:1> ] <EOL> mock_check_output . return_value = '<STR_LIT>' <EOL> interfaces = iflist ( ) <EOL> with self . assertRaises ( IndexError ) : <EOL> name , addr , mask = interfaces [ <NUM_LIT:0> ] </s>
