"""The venue's identity (6R.14): name, slogan, colours, logos, Wi-Fi and contact saved together, logos protected in the media library, signage screens told and given it with their venue.""" from tests.test_live import err, owner_h, pair # noqa: F401 (fixtures) from tests.test_media import jpeg, media_dir, up # noqa: F401 (fixture + helpers) from tests.test_signage import screens, sent # noqa: F401 (fixtures) def test_empty_at_first(client, owner_h): r = client.get("/api/identity", headers=owner_h) assert r.status_code == 200 j = r.json() assert j["colours"] == [] and j["logos"] == {"main": None, "light": None, "dark": None, "icon": None} assert j["wifi"]["security"] == "WPA" and j["contact"]["phone"] is None def test_saved_together_and_shown_to_the_screens(client, owner_h, screens, sent, media_dir): logo = up(client, owner_h, jpeg(400, 200)).json() body = {"name": " Taverna Xenia ", "slogan": "Since 1987", "colours": [{"name": "Main", "colour": "#1E3A8A"}, {"name": "Olive", "colour": "#556b2f80"}], "logos": {"main": logo["id"]}, "wifi": {"ssid": "Xenia Guests", "password": "kalimera 2026", "security": "WPA"}, "contact": {"phone": " 2310 123456 ", "instagram": "@xenia"}} sent.clear() r = client.put("/api/identity", headers=owner_h, json=body) assert r.status_code == 200, r.text j = r.json() assert j["name"] == "Taverna Xenia" and j["slogan"] == "Since 1987" assert j["colours"] == [{"name": "Main", "colour": "#1e3a8a"}, {"name": "Olive", "colour": "#556b2f80"}] assert j["logos"]["main"]["id"] == logo["id"] and j["logos"]["main"]["card"] assert j["wifi"]["password"] == "kalimera 2026" and j["contact"]["phone"] == "2310 123456" assert ("signage.changed", sorted([screens[1]["id"], screens[2]["id"]])) in sent # the venue name is the one every app already reads assert client.get("/api/settings/", headers=owner_h).json()["venue.name"]["value"] == "Taverna Xenia" # the screens get it with their venue venue = client.get("/api/signage/screen", headers=screens[1]["h"]).json()["venue"] assert venue["name"] == "Taverna Xenia" and venue["identity"]["wifi"]["ssid"] == "Xenia Guests" assert venue["identity"]["logos"]["main"]["id"] == logo["id"] # a logo in use can't be deleted assert err(client.delete(f"/api/media/{logo['id']}", headers=owner_h)) == "media.in_use" def test_checked(client, owner_h): assert client.put("/api/identity", headers=owner_h, json={"colours": [{"name": "", "colour": "#000000"}]}).status_code == 422 assert client.put("/api/identity", headers=owner_h, json={"colours": [{"name": "x", "colour": "red"}]}).status_code == 422 assert client.put("/api/identity", headers=owner_h, json={"wifi": {"security": "WPA9"}}).status_code == 422 assert client.put("/api/identity", headers=owner_h, json={"nope": 1}).status_code == 422 assert err(client.put("/api/identity", headers=owner_h, json={"logos": {"main": 99999}})) == "media.not_found" too_many = [{"name": f"c{i}", "colour": "#000000"} for i in range(13)] assert client.put("/api/identity", headers=owner_h, json={"colours": too_many}).status_code == 422