<s> import logging <EOL> import unittest <EOL> import sys <EOL> sys . path . append ( '<STR_LIT>' ) <EOL> from nipap . backend import Nipap <EOL> from nipap . authlib import SqliteAuth <EOL> from nipap . nipapconfig import NipapConfig <EOL> logger = logging . getLogger ( ) <EOL> logger . setLevel ( logging . DEBUG ) <EOL> log_format = "<STR_LIT>" <EOL> import xmlrpclib <EOL> server_url = "<STR_LIT>" <EOL> s = xmlrpclib . Server ( server_url , allow_none = <NUM_LIT:1> ) ; <EOL> ad = { '<STR_LIT>' : '<STR_LIT>' } <EOL> nipap_bin = '<STR_LIT>' <EOL> class NipapCliTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> maxDiff = None <EOL> logger = None <EOL> cfg = None <EOL> nipap = None <EOL> def setUp ( self ) : <EOL> self . logger = logging . getLogger ( self . __class__ . __name__ ) <EOL> self . cfg = NipapConfig ( '<STR_LIT>' ) <EOL> self . nipap = Nipap ( ) <EOL> self . auth = SqliteAuth ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . auth . authenticated_as = '<STR_LIT>' <EOL> self . auth . full_name = '<STR_LIT>' <EOL> self . nipap . _execute ( "<STR_LIT>" ) <EOL> self . nipap . _execute ( "<STR_LIT>" ) <EOL> self . nipap . _execute ( "<STR_LIT>" ) <EOL> self . nipap . _execute ( "<STR_LIT>" ) <EOL> self . nipap . _execute ( "<STR_LIT>" ) <EOL> self . nipap . _execute ( "<STR_LIT>" ) <EOL> def _mangle_prefix_result ( self , res ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( res , list ) : <EOL> for p in res : <EOL> self . assertIn ( '<STR_LIT>' , p ) <EOL> self . assertIn ( '<STR_LIT>' , p ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> elif isinstance ( res , dict ) and '<STR_LIT:result>' in res : <EOL> for p in res [ '<STR_LIT:result>' ] : <EOL> self . assertIn ( '<STR_LIT>' , p ) <EOL> self . assertIn ( '<STR_LIT>' , p ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> elif isinstance ( res , dict ) : <EOL> self . assertIn ( '<STR_LIT>' , p ) <EOL> self . assertIn ( '<STR_LIT>' , p ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( p [ '<STR_LIT>' ] ) <EOL> del ( res [ '<STR_LIT>' ] ) <EOL> del ( res [ '<STR_LIT>' ] ) <EOL> del ( res [ '<STR_LIT>' ] ) <EOL> return res <EOL> def _run_cmd ( self , cmd ) : <EOL> """<STR_LIT>""" <EOL> import subprocess <EOL> return subprocess . check_output ( cmd ) <EOL> def test_prefix_add_list ( self ) : <EOL> """<STR_LIT>""" <EOL> ref = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:true>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> cmd = [ nipap_bin , '<STR_LIT:address>' , '<STR_LIT>' ] <EOL> for key in ref : <EOL> cmd . append ( key ) <EOL> cmd . append ( ref [ key ] ) <EOL> ref [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ref [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> ref [ '<STR_LIT>' ] = <NUM_LIT:4> <EOL> ref [ '<STR_LIT>' ] = True <EOL> ref [ '<STR_LIT>' ] = None <EOL> ref [ '<STR_LIT>' ] = None <EOL> ref [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> ref [ '<STR_LIT>' ] = '<STR_LIT:default>' <EOL> ref [ '<STR_LIT>' ] = None <EOL> ref [ '<STR_LIT>' ] = None <EOL> ref [ '<STR_LIT>' ] = None <EOL> ref [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ref [ '<STR_LIT>' ] = None <EOL> ref [ '<STR_LIT>' ] = [ ] <EOL> ref [ '<STR_LIT>' ] = [ ] <EOL> ref [ '<STR_LIT>' ] = { } <EOL> ref [ '<STR_LIT>' ] = None <EOL> self . _run_cmd ( cmd ) <EOL> res = self . _mangle_prefix_result ( s . list_prefix ( { '<STR_LIT>' : ad , '<STR_LIT>' : { } } ) ) <EOL> del ( res [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( res , [ ref , ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> log = logging . getLogger ( ) <EOL> logging . basicConfig ( ) <EOL> log . setLevel ( logging . INFO ) <EOL> if sys . version_info >= ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> unittest . main ( verbosity = <NUM_LIT:2> ) <EOL> else : <EOL> unittest . main ( ) </s>
