1
+ import json
1
2
from mock import Mock , ANY , patch
2
3
3
- from jupyterlab_git .handlers import GitUpstreamHandler , GitPushHandler , setup_handlers
4
+ from jupyterlab_git .handlers import GitAllHistoryHandler , GitUpstreamHandler , GitPushHandler , setup_handlers
4
5
5
6
6
7
def test_mapping_added ():
@@ -17,7 +18,7 @@ def test_mapping_added():
17
18
@patch ('jupyterlab_git.handlers.GitUpstreamHandler.get_json_body' , Mock (return_value = {'current_path' : 'test_path' }))
18
19
@patch ('jupyterlab_git.handlers.GitUpstreamHandler.git' )
19
20
@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 ):
21
22
# Given
22
23
mock_git .get_current_branch .return_value = 'foo'
23
24
mock_git .get_upstream_branch .return_value = 'bar'
@@ -31,6 +32,42 @@ def test_push_handler_localbranch(mock_finish, mock_git):
31
32
mock_finish .assert_called_with ('{"upstream": "bar"}' )
32
33
33
34
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
+
34
71
@patch ('jupyterlab_git.handlers.GitPushHandler.__init__' , Mock (return_value = None ))
35
72
@patch ('jupyterlab_git.handlers.GitPushHandler.get_json_body' , Mock (return_value = {'current_path' : 'test_path' }))
36
73
@patch ('jupyterlab_git.handlers.GitPushHandler.git' )
0 commit comments