Skip to content

Commit aa4e0c6

Browse files
fcollonvaltelamonian
authored andcommitted
Test log
1 parent db77f77 commit aa4e0c6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

jupyterlab_git/tests/test_handlers.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from jupyterlab_git.handlers import (
55
GitAllHistoryHandler,
66
GitBranchHandler,
7+
GitLogHandler,
78
GitPushHandler,
89
GitUpstreamHandler,
910
setup_handlers
@@ -120,6 +121,38 @@ def test_branch_handler_localbranch(mock_finish, mock_git):
120121
'branches': branch['branches']
121122
}))
122123

124+
@patch('jupyterlab_git.handlers.GitLogHandler.__init__', Mock(return_value=None))
125+
@patch('jupyterlab_git.handlers.GitLogHandler.get_json_body', Mock(return_value={'current_path': 'test_path', 'history_count': 20}))
126+
@patch('jupyterlab_git.handlers.GitLogHandler.git')
127+
@patch('jupyterlab_git.handlers.GitLogHandler.finish')
128+
def test_log_handler(mock_finish, mock_git):
129+
# Given
130+
log = {'code': 0, 'commits': []}
131+
mock_git.log.return_value = log
132+
133+
# When
134+
GitLogHandler().post()
135+
136+
# Then
137+
mock_git.log.assert_called_with('test_path', 20)
138+
mock_finish.assert_called_with(json.dumps(log))
139+
140+
141+
@patch('jupyterlab_git.handlers.GitLogHandler.__init__', Mock(return_value=None))
142+
@patch('jupyterlab_git.handlers.GitLogHandler.get_json_body', Mock(return_value={'current_path': 'test_path'}))
143+
@patch('jupyterlab_git.handlers.GitLogHandler.git')
144+
@patch('jupyterlab_git.handlers.GitLogHandler.finish')
145+
def test_log_handler_no_history_count(mock_finish, mock_git):
146+
# Given
147+
log = {'code': 0, 'commits': []}
148+
mock_git.log.return_value = log
149+
150+
# When
151+
GitLogHandler().post()
152+
153+
# Then
154+
mock_git.log.assert_called_with('test_path', 25)
155+
mock_finish.assert_called_with(json.dumps(log))
123156

124157

125158
@patch('jupyterlab_git.handlers.GitPushHandler.__init__', Mock(return_value=None))

0 commit comments

Comments
 (0)