Skip to content

Commit

Permalink
fix tests: api/test_file_api
Browse files Browse the repository at this point in the history
  • Loading branch information
jokester committed Jun 9, 2024
1 parent dee3876 commit 772ae1e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test_all_parallel:
venv/bin/pytest -n 8

test_single:
venv/bin/pytest tests/base/test_not_exist_error.py
venv/bin/pytest tests/api/test_file_api.py

test_logging:
#--capture=no
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[pytest]
generate_report_on_test = True
; 覆盖率配置,需要时开启(可配合VSCode的Coverage Gutters使用)
addopts = --log-level=INFO
addopts = --log-level=DEBUG --capture=no
; 忽略第三方库Warining
filterwarnings =
ignore:count is deprecated. Use Collection.count_documents instead.:DeprecationWarning
Expand Down
4 changes: 2 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def open(self, *args, **kwargs):
if kwargs.get("headers") is None:
kwargs["headers"] = {
# 默认增加跨域参数
"Origin": "https://example.com"
"Origin": "https://example.com",
}
# 如果给予data参数,则转换为json,并设置json内容头
json_data = kwargs.pop("json", None)
if json_data:
if isinstance(json_data, dict):
kwargs["data"] = json.dumps(json_data)
kwargs["headers"]["Content-Type"] = "application/json"
token = kwargs.pop("token", None)
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def test_edit_file_name(self):
)
self.assertErrorEqual(data, NoPermissionError)
# == 缺少filename ==
data = self.put("/v1/files/{}".format(file1.id), token=token)
data = self.put("/v1/files/{}".format(file1.id), json={}, token=token)
self.assertErrorEqual(data, ValidateError)
# == 错误的名字 ==
data = self.put(
Expand Down Expand Up @@ -300,7 +300,7 @@ def test_move_file(self):
)
self.assertErrorEqual(data, NoPermissionError)
# == 缺少parent_id ==
data = self.put("/v1/files/{}".format(file1.id), token=token)
data = self.put("/v1/files/{}".format(file1.id), json={}, token=token)
self.assertErrorEqual(data, ValidateError)
# == 缺少parent_id,null等同于缺少 ==
data = self.put(
Expand Down

0 comments on commit 772ae1e

Please sign in to comment.