1+ import json
12from mock import Mock , ANY , patch
23
3- from jupyterlab_git .handlers import GitUpstreamHandler , GitPushHandler , setup_handlers
4+ from jupyterlab_git .handlers import GitAllHistoryHandler , GitUpstreamHandler , GitPushHandler , setup_handlers
45
56
67def test_mapping_added ():
@@ -17,7 +18,7 @@ def test_mapping_added():
1718@patch ('jupyterlab_git.handlers.GitUpstreamHandler.get_json_body' , Mock (return_value = {'current_path' : 'test_path' }))
1819@patch ('jupyterlab_git.handlers.GitUpstreamHandler.git' )
1920@patch ('jupyterlab_git.handlers.GitUpstreamHandler.finish' )
20- def test_push_handler_localbranch (mock_finish , mock_git ):
21+ def test_upstream_handler_localbranch (mock_finish , mock_git ):
2122 # Given
2223 mock_git .get_current_branch .return_value = 'foo'
2324 mock_git .get_upstream_branch .return_value = 'bar'
@@ -31,6 +32,42 @@ def test_push_handler_localbranch(mock_finish, mock_git):
3132 mock_finish .assert_called_with ('{"upstream": "bar"}' )
3233
3334
35+ @patch ('jupyterlab_git.handlers.GitAllHistoryHandler.__init__' , Mock (return_value = None ))
36+ @patch ('jupyterlab_git.handlers.GitAllHistoryHandler.get_json_body' , Mock (return_value = {'current_path' : 'test_path' , 'history_count' : 25 }))
37+ @patch ('jupyterlab_git.handlers.GitAllHistoryHandler.git' )
38+ @patch ('jupyterlab_git.handlers.GitAllHistoryHandler.finish' )
39+ def test_all_history_handler_localbranch (mock_finish , mock_git ):
40+ # Given
41+ show_top_level = {'code' : 0 , 'foo' : 'top_level' }
42+ branch = 'branch_foo'
43+ log = 'log_foo'
44+ status = 'status_foo'
45+
46+ mock_git .show_top_level .return_value = show_top_level
47+ mock_git .branch .return_value = branch
48+ mock_git .log .return_value = log
49+ mock_git .status .return_value = status
50+
51+ # When
52+ GitAllHistoryHandler ().post ()
53+
54+ # Then
55+ mock_git .show_top_level .assert_called_with ('test_path' )
56+ mock_git .branch .assert_called_with ('test_path' )
57+ mock_git .log .assert_called_with ('test_path' , 25 )
58+ mock_git .status .assert_called_with ('test_path' )
59+
60+ mock_finish .assert_called_with (json .dumps ({
61+ 'code' : show_top_level ['code' ],
62+ 'data' : {
63+ 'show_top_level' : show_top_level ,
64+ 'branch' : branch ,
65+ 'log' : log ,
66+ 'status' : status ,
67+ }
68+ }))
69+
70+
3471@patch ('jupyterlab_git.handlers.GitPushHandler.__init__' , Mock (return_value = None ))
3572@patch ('jupyterlab_git.handlers.GitPushHandler.get_json_body' , Mock (return_value = {'current_path' : 'test_path' }))
3673@patch ('jupyterlab_git.handlers.GitPushHandler.git' )
0 commit comments