#NEWLINE# @ patch ( 'subprocess.Popen' ) #NEWLINE# def test_get_pem_certificate( self , mock_popen ) : #NEWLINE# #INDENT# mock_openssl = mock . Mock ( ) #NEWLINE# mock_openssl . communicate = mock . Mock ( return_value = [ 'SHA1 Fingerprint=02:8F:82' , 'error' ] ) #NEWLINE# mock_openssl . returncode = 0 #NEWLINE# mock_popen . return_value = mock_openssl #NEWLINE# self . cloud_service . get_pem_certificate ( 'ssh-private-key' ) #NEWLINE# mock_popen . assert_called_once_with ( [ 'openssl' , 'req' , '-x509' , '-key' , 'ssh-private-key' , '-days' , '365' , '-subj' , '/C=US/ST=Denial/L=Denial/O=Dis/CN=www.azure.com' , '-newkey' , 'rsa:2048' ] , stderr = ( - 1 ) , stdout = ( - 1 ) )