99from sparkmagic .serverextension .handlers import ReconnectHandler
1010from sparkmagic .kernels .kernelmagics import KernelMagics
1111import sparkmagic .utils .configuration as conf
12+ from sparkmagic .utils import constants
1213
1314
1415class SimpleObject (object ):
@@ -30,6 +31,7 @@ class TestSparkMagicHandler(AsyncTestCase):
3031 username = 'username'
3132 password = 'password'
3233 endpoint = 'http://endpoint.com'
34+ auth_type = constants .AUTH_BASIC
3335 response_id = '0'
3436 good_msg = dict (content = dict (status = 'ok' ))
3537 bad_msg = dict (content = dict (status = 'error' , ename = 'SyntaxError' , evalue = 'oh no!' ))
@@ -62,7 +64,7 @@ def setUp(self):
6264
6365 # Mock request
6466 self .request = MagicMock ()
65- self .request .body = json .dumps ({"path" : self .path , "username" : self .username , "password" : self .password , "endpoint" : self .endpoint })
67+ self .request .body = json .dumps ({"path" : self .path , "username" : self .username , "password" : self .password , "endpoint" : self .endpoint , "auth_type" : self . auth_type })
6668
6769 # Create mocked reconnect_handler
6870 ReconnectHandler .__bases__ = (SimpleObject ,)
@@ -124,7 +126,7 @@ def test_post_existing_kernel(self, _get_kernel_manager):
124126 res = yield self .reconnect_handler .post ()
125127 assert_equals (res , None )
126128
127- code = '%{} -s {} -u {} -p {}' .format (KernelMagics ._do_not_call_change_endpoint .__name__ , self .endpoint , self .username , self .password )
129+ code = '%{} -s {} -u {} -p {} -t {} ' .format (KernelMagics ._do_not_call_change_endpoint .__name__ , self .endpoint , self .username , self .password , self . auth_type )
128130 self .client .execute .assert_called_once_with (code , silent = False , store_history = False )
129131 self .reconnect_handler .set_status .assert_called_once_with (200 )
130132 self .reconnect_handler .finish .assert_called_once_with ('{"error": null, "success": true}' )
@@ -141,7 +143,7 @@ def test_post_existing_kernel_failed(self, _get_kernel_manager):
141143 res = yield self .reconnect_handler .post ()
142144 assert_equals (res , None )
143145
144- code = '%{} -s {} -u {} -p {}' .format (KernelMagics ._do_not_call_change_endpoint .__name__ , self .endpoint , self .username , self .password )
146+ code = '%{} -s {} -u {} -p {} -t {} ' .format (KernelMagics ._do_not_call_change_endpoint .__name__ , self .endpoint , self .username , self .password , self . auth_type )
145147 self .client .execute .assert_called_once_with (code , silent = False , store_history = False )
146148 self .reconnect_handler .set_status .assert_called_once_with (500 )
147149 self .reconnect_handler .finish .assert_called_once_with ('{"error": "SyntaxError:\\ noh no!", "success": false}' )
0 commit comments