<s> """<STR_LIT>""" <EOL> import unittest <EOL> from ganeti import compat <EOL> from ganeti import constants <EOL> from ganeti import errors <EOL> from ganeti import opcodes <EOL> from ganeti import luxi <EOL> from ganeti import rapi <EOL> from ganeti import utils <EOL> import ganeti . rapi . testutils <EOL> import ganeti . rapi . client <EOL> import testutils <EOL> KNOWN_UNUSED_LUXI = compat . UniqueFrozenset ( [ <EOL> luxi . REQ_SUBMIT_MANY_JOBS , <EOL> luxi . REQ_SUBMIT_JOB_TO_DRAINED_QUEUE , <EOL> luxi . REQ_ARCHIVE_JOB , <EOL> luxi . REQ_AUTO_ARCHIVE_JOBS , <EOL> luxi . REQ_CHANGE_JOB_PRIORITY , <EOL> luxi . REQ_PICKUP_JOB , <EOL> luxi . REQ_QUERY_EXPORTS , <EOL> luxi . REQ_QUERY_CONFIG_VALUES , <EOL> luxi . REQ_QUERY_NETWORKS , <EOL> luxi . REQ_QUERY_TAGS , <EOL> luxi . REQ_SET_DRAIN_FLAG , <EOL> luxi . REQ_SET_WATCHER_PAUSE , <EOL> ] ) <EOL> _used_luxi_calls = None <EOL> class TestHideInternalErrors ( unittest . TestCase ) : <EOL> def test ( self ) : <EOL> def inner ( ) : <EOL> raise errors . GenericError ( "<STR_LIT:error>" ) <EOL> fn = rapi . testutils . _HideInternalErrors ( inner ) <EOL> self . assertRaises ( rapi . testutils . VerificationError , fn ) <EOL> class TestVerifyOpInput ( unittest . TestCase ) : <EOL> def testUnknownOpId ( self ) : <EOL> voi = rapi . testutils . VerifyOpInput <EOL> self . assertRaises ( rapi . testutils . VerificationError , voi , "<STR_LIT>" , None ) <EOL> def testUnknownParameter ( self ) : <EOL> voi = rapi . testutils . VerifyOpInput <EOL> self . assertRaises ( rapi . testutils . VerificationError , voi , <EOL> opcodes . OpClusterRename . OP_ID , { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } ) <EOL> def testWrongParameterValue ( self ) : <EOL> voi = rapi . testutils . VerifyOpInput <EOL> self . assertRaises ( rapi . testutils . VerificationError , voi , <EOL> opcodes . OpClusterRename . OP_ID , { <EOL> "<STR_LIT:name>" : object ( ) , <EOL> } ) <EOL> def testSuccess ( self ) : <EOL> voi = rapi . testutils . VerifyOpInput <EOL> voi ( opcodes . OpClusterRename . OP_ID , { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> } ) <EOL> class TestVerifyOpResult ( unittest . TestCase ) : <EOL> def testSuccess ( self ) : <EOL> vor = rapi . testutils . VerifyOpResult <EOL> vor ( opcodes . OpClusterVerify . OP_ID , { <EOL> constants . JOB_IDS_KEY : [ <EOL> ( False , "<STR_LIT>" ) , <EOL> ] , <EOL> } ) <EOL> def testWrongResult ( self ) : <EOL> vor = rapi . testutils . VerifyOpResult <EOL> self . assertRaises ( rapi . testutils . VerificationError , vor , <EOL> opcodes . OpClusterVerify . OP_ID , [ ] ) <EOL> def testNoResultCheck ( self ) : <EOL> vor = rapi . testutils . VerifyOpResult <EOL> vor ( opcodes . OpTestDummy . OP_ID , None ) <EOL> class TestInputTestClient ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . cl = rapi . testutils . InputTestClient ( ) <EOL> def tearDown ( self ) : <EOL> _used_luxi_calls . update ( self . cl . _GetLuxiCalls ( ) ) <EOL> def testGetInfo ( self ) : <EOL> self . assertTrue ( self . cl . GetInfo ( ) is NotImplemented ) <EOL> def testPrepareExport ( self ) : <EOL> result = self . cl . PrepareExport ( "<STR_LIT>" , <EOL> constants . EXPORT_MODE_LOCAL ) <EOL> self . assertTrue ( result is NotImplemented ) <EOL> self . assertRaises ( rapi . testutils . VerificationError , self . cl . PrepareExport , <EOL> "<STR_LIT>" , "<STR_LIT>" ) <EOL> def testGetJobs ( self ) : <EOL> self . assertTrue ( self . cl . GetJobs ( ) is NotImplemented ) <EOL> def testQuery ( self ) : <EOL> result = self . cl . Query ( constants . QR_NODE , [ "<STR_LIT:name>" ] ) <EOL> self . assertTrue ( result is NotImplemented ) <EOL> def testQueryFields ( self ) : <EOL> result = self . cl . QueryFields ( constants . QR_INSTANCE ) <EOL> self . assertTrue ( result is NotImplemented ) <EOL> def testCancelJob ( self ) : <EOL> self . assertTrue ( self . cl . CancelJob ( "<STR_LIT:1>" ) is NotImplemented ) <EOL> def testGetNodes ( self ) : <EOL> self . assertTrue ( self . cl . GetNodes ( ) is NotImplemented ) <EOL> def testGetInstances ( self ) : <EOL> self . assertTrue ( self . cl . GetInstances ( ) is NotImplemented ) <EOL> def testGetGroups ( self ) : <EOL> self . assertTrue ( self . cl . GetGroups ( ) is NotImplemented ) <EOL> def testWaitForJobChange ( self ) : <EOL> result = self . cl . WaitForJobChange ( "<STR_LIT:1>" , [ "<STR_LIT:id>" ] , None , None ) <EOL> self . assertTrue ( result is NotImplemented ) <EOL> def testGetFilters ( self ) : <EOL> self . assertTrue ( self . cl . GetFilters ( ) is NotImplemented ) <EOL> def testGetFilter ( self ) : <EOL> result = self . cl . GetFilter ( "<STR_LIT>" ) <EOL> self . assertTrue ( result is NotImplemented ) <EOL> def testReplaceFilter ( self ) : <EOL> self . assertTrue ( self . cl . ReplaceFilter ( <EOL> uuid = "<STR_LIT>" , <EOL> priority = <NUM_LIT:1> , <EOL> predicates = [ [ "<STR_LIT>" , [ "<STR_LIT:>>" , "<STR_LIT:id>" , "<STR_LIT>" ] ] ] , <EOL> action = "<STR_LIT>" , <EOL> reason_trail = [ "<STR_LIT>" , "<STR_LIT>" , utils . EpochNano ( ) ] , <EOL> ) is NotImplemented ) <EOL> def testAddFilter ( self ) : <EOL> self . assertTrue ( self . cl . AddFilter ( <EOL> priority = <NUM_LIT:1> , <EOL> predicates = [ [ "<STR_LIT>" , [ "<STR_LIT:>>" , "<STR_LIT:id>" , "<STR_LIT>" ] ] ] , <EOL> action = "<STR_LIT>" , <EOL> reason_trail = [ "<STR_LIT>" , "<STR_LIT>" , utils . EpochNano ( ) ] , <EOL> ) is NotImplemented ) <EOL> def testDeleteFilter ( self ) : <EOL> self . assertTrue ( self . cl . DeleteFilter ( <EOL> uuid = "<STR_LIT>" , <EOL> ) is NotImplemented ) <EOL> class CustomTestRunner ( unittest . TextTestRunner ) : <EOL> def run ( self , * args ) : <EOL> global _used_luxi_calls <EOL> assert _used_luxi_calls is None <EOL> diff = ( KNOWN_UNUSED_LUXI - luxi . REQ_ALL ) <EOL> assert not diff , "<STR_LIT>" % diff <EOL> _used_luxi_calls = set ( ) <EOL> try : <EOL> result = unittest . TextTestRunner . run ( self , * args ) <EOL> diff = _used_luxi_calls & KNOWN_UNUSED_LUXI <EOL> if diff : <EOL> raise AssertionError ( "<STR_LIT>" % <EOL> utils . CommaJoin ( diff ) ) <EOL> diff = ( luxi . REQ_ALL - KNOWN_UNUSED_LUXI - _used_luxi_calls ) <EOL> if diff : <EOL> raise AssertionError ( "<STR_LIT>" % <EOL> utils . CommaJoin ( diff ) ) <EOL> finally : <EOL> _used_luxi_calls = None <EOL> return result <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> testutils . GanetiTestProgram ( testRunner = CustomTestRunner ) </s>
