Skip to content

Commit 24d991f

Browse files
committed
Fix unit test
1 parent 298286e commit 24d991f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

jupyterlab_git/tests/test_handlers.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def test_diffcontent_show_unhandled_error(self, mock_execute):
679679
self.tester.post(["diffcontent"], body=body)
680680

681681
@patch("jupyterlab_git.git.execute")
682-
def test_diffcontent_getcontent_error(self, mock_execute):
682+
def test_diffcontent_getcontent_deleted_file(self, mock_execute):
683683
# Given
684684
top_repo_path = "path/to/repo"
685685
filename = "my/absent_file"
@@ -688,7 +688,6 @@ def test_diffcontent_getcontent_error(self, mock_execute):
688688
mock_execute.side_effect = [
689689
maybe_future((0, "1\t1\t{}".format(filename), "")),
690690
maybe_future((0, content, "")),
691-
maybe_future((0, content, "")),
692691
]
693692

694693
# When
@@ -699,5 +698,18 @@ def test_diffcontent_getcontent_error(self, mock_execute):
699698
"top_repo_path": top_repo_path,
700699
}
701700
# Then
702-
with assert_http_error(404, msg="No such file or directory"):
703-
self.tester.post(["diffcontent"], body=body)
701+
response = self.tester.post(["diffcontent"], body=body)
702+
703+
# Then
704+
assert response.status_code == 200
705+
payload = response.json()
706+
assert payload["prev_content"] == content
707+
assert payload["curr_content"] == ""
708+
mock_execute.assert_has_calls(
709+
[
710+
call(
711+
["git", "show", "{}:{}".format("previous", filename)],
712+
cwd=os.path.join(self.notebook_dir, top_repo_path),
713+
)
714+
]
715+
)

0 commit comments

Comments
 (0)