|
4 | 4 | from jupyterlab_git.handlers import (
|
5 | 5 | GitAllHistoryHandler,
|
6 | 6 | GitBranchHandler,
|
| 7 | + GitLogHandler, |
7 | 8 | GitPushHandler,
|
8 | 9 | GitUpstreamHandler,
|
9 | 10 | setup_handlers
|
@@ -120,6 +121,38 @@ def test_branch_handler_localbranch(mock_finish, mock_git):
|
120 | 121 | 'branches': branch['branches']
|
121 | 122 | }))
|
122 | 123 |
|
| 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)) |
123 | 156 |
|
124 | 157 |
|
125 | 158 | @patch('jupyterlab_git.handlers.GitPushHandler.__init__', Mock(return_value=None))
|
|
0 commit comments