fix bugs
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
from PIL import Image as PILImage
|
||||
|
||||
from spectra.web.server import create_app
|
||||
@@ -18,11 +18,16 @@ def app():
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
tmp = Path(tmpdir)
|
||||
cache_dir = tmp / "cache"
|
||||
config_path = tmp / "config.yaml"
|
||||
|
||||
# Write a minimal config so ConfigManager writes into the temp dir
|
||||
with open(config_path, "w") as f:
|
||||
yaml.dump({"display": {"saturation": 0.5}}, f)
|
||||
|
||||
old_environ = os.environ.get("SPECTRA_CACHE_DIR")
|
||||
os.environ["SPECTRA_CACHE_DIR"] = str(cache_dir)
|
||||
|
||||
app = create_app()
|
||||
app = create_app(config_path=str(config_path))
|
||||
|
||||
yield app
|
||||
|
||||
|
||||
@@ -203,7 +203,6 @@ class TestDisplayAPI:
|
||||
resp = client.get("/api/display/status")
|
||||
assert resp.status_code == 200
|
||||
data = resp.get_json()
|
||||
assert "simulate" in data
|
||||
assert "resolution" in data
|
||||
assert "pending_trigger" in data
|
||||
|
||||
@@ -318,12 +317,14 @@ class TestCORSAndErrors:
|
||||
data = resp.get_json()
|
||||
assert "error" in data
|
||||
|
||||
def test_url_encoded_form_not_accepted(self, client):
|
||||
def test_url_encoded_form_accepted(self, client):
|
||||
resp = client.put(
|
||||
"/api/config/display/saturation",
|
||||
data={"value": "0.5"},
|
||||
)
|
||||
assert resp.status_code == 400 or resp.status_code == 200
|
||||
assert resp.status_code == 200
|
||||
resp = client.get("/api/config/display")
|
||||
assert resp.get_json()["saturation"] == 0.5
|
||||
|
||||
|
||||
class TestGallery:
|
||||
|
||||
Reference in New Issue
Block a user