Check every setting before the first one is stored
A bad value in a settings request no longer leaves the other values of that request saved.
This commit is contained in:
@@ -280,6 +280,33 @@ def test_delete_revisions(client):
|
||||
assert [r["rev"] for r in client.get(f"/api/chapters/{chapter_id}/diff").json["revisions"]] == [1, 3]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"bad",
|
||||
[
|
||||
{"recent_chapters": "many"},
|
||||
{"main_jobs_count": 100000},
|
||||
{"personal_ini": "[defaults\nfoo"},
|
||||
{"link_books": "yes"},
|
||||
],
|
||||
)
|
||||
def test_a_bad_setting_changes_no_setting(client, monkeypatch, tmp_path, bad):
|
||||
ini = tmp_path / "personal.ini"
|
||||
ini.write_text("[defaults]\n")
|
||||
monkeypatch.setattr(config, "PERSONAL_INI", ini)
|
||||
monkeypatch.setattr(config, "CWA_URL", "https://cwa.invalid")
|
||||
before = client.get("/api/settings").json
|
||||
good = {
|
||||
"link_books": False,
|
||||
"hold_new_links": True,
|
||||
"pause_uploads": True,
|
||||
"recent_chapters": 4,
|
||||
"story_jobs_hours": 1,
|
||||
"personal_ini": "[defaults]\nis_adult:true\n",
|
||||
}
|
||||
assert client.put("/api/settings", json={**good, **bad}, headers=H).status_code == 400
|
||||
assert client.get("/api/settings").json == before
|
||||
|
||||
|
||||
def test_settings(client, monkeypatch, tmp_path):
|
||||
ini = tmp_path / "personal.ini"
|
||||
ini.write_text("[defaults]\nis_adult:true\n")
|
||||
|
||||
Reference in New Issue
Block a user