feat(A05 가이드 캡처): 장면 account(sys · company_admin · user) 계정별 컨텍스트 · callouts sel 목록 묶음 상자 · 번호 원 화면 안 밀기 · 시험 덧
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -189,3 +189,73 @@ def test_callout_and_clip_boxes():
|
||||
clip = G.union_clip([ring, dot], 16, 1600, 900)
|
||||
assert clip["x"] <= dot["x"] - 16 + 0.01 and clip["width"] > ring["w"]
|
||||
assert G.union_clip([{"x": -50, "y": 0, "w": 2000, "h": 10}], 16, 1600, 900)["width"] == 1600
|
||||
|
||||
|
||||
@pytest.mark.parametrize("acct", ["sys", "company_admin", "user"])
|
||||
def test_account_ok(acct):
|
||||
assert G.check_scene(_scene(account=acct), "B05") == []
|
||||
|
||||
|
||||
def test_account_bad():
|
||||
assert G.check_scene(_scene(account="admin"), "B05")
|
||||
|
||||
|
||||
def test_callout_sel_list():
|
||||
ok = _scene(callouts=[{"n": 1, "sel": [".a", ".b"]}, {"n": 2, "sel": ".c"}])
|
||||
assert G.check_scene(ok, "B05") == []
|
||||
for bad in ([], [""], [".a", 3], 5, None):
|
||||
assert G.check_scene(_scene(callouts=[{"n": 1, "sel": bad}]), "B05")
|
||||
|
||||
|
||||
def test_union_box_and_ring():
|
||||
u = G.union_box(
|
||||
[
|
||||
{"x": 10, "y": 20, "width": 30, "height": 10},
|
||||
{"x": 100, "y": 5, "width": 20, "height": 10},
|
||||
]
|
||||
)
|
||||
assert u == {"x": 10, "y": 5, "width": 110, "height": 25}
|
||||
ring, _ = G.callout_boxes(u, "tl", 1600, 900)
|
||||
assert ring == {"x": 6, "y": 1, "w": 118, "h": 33}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pos", ["tl", "tr", "bl", "br"])
|
||||
def test_dot_pushed_inside_only_when_overflow(pos):
|
||||
vw, vh = 800, 600
|
||||
# 화면 모서리에 붙은 요소 → 원이 밖으로 나갈 자리 = 안으로
|
||||
for box in (
|
||||
{"x": 0, "y": 0, "width": 800, "height": 600},
|
||||
{"x": 790, "y": 590, "width": 10, "height": 10},
|
||||
):
|
||||
_, dot = G.callout_boxes(box, pos, vw, vh)
|
||||
assert 0 <= dot["x"] and dot["x"] + dot["w"] <= vw
|
||||
assert 0 <= dot["y"] and dot["y"] + dot["h"] <= vh
|
||||
# 안쪽 요소 → 원 자리 그대로(바깥 모서리 20px 걸침)
|
||||
ring, dot = G.callout_boxes({"x": 300, "y": 300, "width": 100, "height": 50}, pos, vw, vh)
|
||||
assert dot["x"] == (ring["x"] - 20 if pos in ("tl", "bl") else ring["x"] + ring["w"] - 8)
|
||||
assert dot["y"] == (ring["y"] - 20 if pos in ("tl", "tr") else ring["y"] + ring["h"] - 8)
|
||||
|
||||
|
||||
def test_account_cred(tmp_path, monkeypatch):
|
||||
f = tmp_path / "acc.json"
|
||||
f.write_text(
|
||||
json.dumps({"회사관리자": {"email": "a@b", "password": "x"}, "일반": {"email": "c@d"}})
|
||||
)
|
||||
sysf = tmp_path / "sys.json"
|
||||
sysf.write_text(json.dumps({"email": "s@s", "password": "y"}))
|
||||
monkeypatch.setattr(G, "ACCOUNTS_FILE", f)
|
||||
monkeypatch.setattr(G, "CRED", sysf)
|
||||
assert G.account_cred("company_admin")["email"] == "a@b"
|
||||
assert G.account_cred("sys")["email"] == "s@s"
|
||||
with pytest.raises(G.SceneError) as e:
|
||||
G.account_cred("user") # password 없음
|
||||
assert "x" not in str(e.value).replace("password", "")
|
||||
monkeypatch.setattr(G, "ACCOUNTS_FILE", tmp_path / "none.json")
|
||||
with pytest.raises(G.SceneError):
|
||||
G.account_cred("company_admin")
|
||||
|
||||
|
||||
def test_list_shows_account(capsys):
|
||||
d = _folder([_scene(account="user")])
|
||||
assert G.main(["--page", "B05", "--out", str(d), "--list"]) == 0
|
||||
assert "user" in capsys.readouterr().out
|
||||
|
||||
Reference in New Issue
Block a user