Skip to content

Commit 7d5cc2c

Browse files
committed
test sending logs
1 parent c4e4b5b commit 7d5cc2c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mergin/test/test_client.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,3 +2845,29 @@ def test_server_config(mc: MerginClient):
28452845
assert "server_type" in config
28462846
assert "version" in config
28472847
assert "server_configured" in config
2848+
2849+
2850+
def test_send_logs(mc: MerginClient, monkeypatch):
2851+
"""Test that logs can be send to the server."""
2852+
test_project = "test_logs_send"
2853+
project = API_USER + "/" + test_project
2854+
project_dir = os.path.join(TMP_DIR, test_project)
2855+
2856+
cleanup(mc, project, [project_dir])
2857+
# prepare local project
2858+
shutil.copytree(TEST_DATA_DIR, project_dir)
2859+
2860+
# create remote project
2861+
mc.create_project_and_push(project, directory=project_dir)
2862+
2863+
# patch mc.server_config() to return empty config which means that logs will be send to the server
2864+
# but it is not configured to accept them so client error with message will be raised
2865+
def server_config(self):
2866+
return {}
2867+
2868+
monkeypatch.setattr(mc, "server_config", server_config.__get__(mc))
2869+
2870+
logs_path = os.path.join(project_dir, ".mergin", "client-log.txt")
2871+
2872+
with pytest.raises(ClientError, match="The requested URL was not found on the server"):
2873+
mc.send_logs(logs_path)

0 commit comments

Comments
 (0)