<s> """<STR_LIT>""" <EOL> import mock <EOL> from oslo_config import cfg <EOL> from nova . cert import rpcapi as cert_rpcapi <EOL> from nova import context <EOL> from nova import test <EOL> CONF = cfg . CONF <EOL> class CertRpcAPITestCase ( test . NoDBTestCase ) : <EOL> def _test_cert_api ( self , method , ** kwargs ) : <EOL> ctxt = context . RequestContext ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> rpcapi = cert_rpcapi . CertAPI ( ) <EOL> self . assertIsNotNone ( rpcapi . client ) <EOL> self . assertEqual ( CONF . cert_topic , rpcapi . client . target . topic ) <EOL> orig_prepare = rpcapi . client . prepare <EOL> with test . nested ( <EOL> mock . patch . object ( rpcapi . client , '<STR_LIT>' ) , <EOL> mock . patch . object ( rpcapi . client , '<STR_LIT>' ) , <EOL> mock . patch . object ( rpcapi . client , '<STR_LIT>' ) , <EOL> ) as ( <EOL> rpc_mock , prepare_mock , csv_mock <EOL> ) : <EOL> prepare_mock . return_value = rpcapi . client <EOL> rpc_mock . return_value = '<STR_LIT:foo>' <EOL> csv_mock . side_effect = ( <EOL> lambda v : orig_prepare ( ) . can_send_version ( ) ) <EOL> retval = getattr ( rpcapi , method ) ( ctxt , ** kwargs ) <EOL> self . assertEqual ( rpc_mock . return_value , retval ) <EOL> prepare_mock . assert_called_once_with ( ) <EOL> rpc_mock . assert_called_once_with ( ctxt , method , ** kwargs ) <EOL> def test_revoke_certs_by_user ( self ) : <EOL> self . _test_cert_api ( '<STR_LIT>' , user_id = '<STR_LIT>' ) <EOL> def test_revoke_certs_by_project ( self ) : <EOL> self . _test_cert_api ( '<STR_LIT>' , <EOL> project_id = '<STR_LIT>' ) <EOL> def test_revoke_certs_by_user_and_project ( self ) : <EOL> self . _test_cert_api ( '<STR_LIT>' , <EOL> user_id = '<STR_LIT>' , <EOL> project_id = '<STR_LIT>' ) <EOL> def test_generate_x509_cert ( self ) : <EOL> self . _test_cert_api ( '<STR_LIT>' , <EOL> user_id = '<STR_LIT>' , <EOL> project_id = '<STR_LIT>' ) <EOL> def test_fetch_ca ( self ) : <EOL> self . _test_cert_api ( '<STR_LIT>' , project_id = '<STR_LIT>' ) <EOL> def test_fetch_crl ( self ) : <EOL> self . _test_cert_api ( '<STR_LIT>' , project_id = '<STR_LIT>' ) <EOL> def test_decrypt_text ( self ) : <EOL> self . _test_cert_api ( '<STR_LIT>' , <EOL> project_id = '<STR_LIT>' , text = '<STR_LIT>' ) </s>
