Skip to content

Commit b9d9857

Browse files
committed
create test_status.py
Add a test of `git status`
1 parent e0b8d46 commit b9d9857

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

jupyterlab_git/tests/test_status.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# python lib
2+
import os
3+
from unittest.mock import Mock, call, patch
4+
5+
import pytest
6+
import tornado
7+
8+
# local lib
9+
from jupyterlab_git.git import Git
10+
11+
from .testutils import FakeContentManager
12+
13+
@pytest.mark.asyncio
14+
async def test_changed_files_index():
15+
with patch("jupyterlab_git.git.execute") as mock_execute:
16+
# Given
17+
process_output = (
18+
"A notebook with spaces.ipynb",
19+
"M notebook with λ.ipynb",
20+
"R renamed_to_θ.py",
21+
"originally_named_π.py",
22+
"?? untracked.ipynb",
23+
)
24+
25+
expected_resonse = [
26+
{"x": "A", "y": " ", "to": "notebook with spaces.ipynb", "from": "notebook with spaces.ipynb"},
27+
{"x": "M", "y": " ", "to": "notebook with λ.ipynb", "from": "notebook with λ.ipynb"},
28+
{"x": "R", "y": " ", "to": "renamed_to_θ.py", "from": "originally_named_π.py"},
29+
{"x": "?", "y": "?", "to": "untracked.ipynb", "from": "untracked.ipynb"},
30+
]
31+
mock_execute.return_value = tornado.gen.maybe_future(
32+
(0, "\x00".join(process_output), "")
33+
34+
)
35+
36+
# When
37+
actual_response = await Git(FakeContentManager("/bin")).status(
38+
current_path="test_curr_path"
39+
)
40+
41+
# Then
42+
mock_execute.assert_called_once_with(
43+
["git", "status", "--porcelain" , "-u", "-z"], cwd="/bin/test_curr_path"
44+
)
45+
46+
assert {"code": 0, "files": expected_resonse} == actual_response

0 commit comments

Comments
 (0)