Fixing formatting of magnification
This commit is contained in:
1 parent
d108cb7149
commit
a617b935d3
4 files changed
+111
-25
No files matched your search
@@ -1,9 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from app.models.attachment_point import AttachmentPoint
|
||||
from app.models.attachment_point_name import AttachmentPointName
|
||||
from app.models.augmented_part import AugmentedPart
|
||||
from app.models.fit import Fit, FitLabel
|
||||
from app.models.part_type import PartType
|
||||
from app.models.scope_info import ScopeInfo
|
||||
from app.models.static_connection import StaticConnection
|
||||
from app.models.sub_part_type import SubPartType
|
||||
from app.services import scope_guide
|
||||
|
||||
@@ -199,7 +202,54 @@ async def test_scopes_page_renders_rows_and_fits(
|
||||
assert "Flip cover 50mm" in body # a matching part in a fit column
|
||||
assert "fit-badge-exact" in body # the exact fit badge
|
||||
assert "M52x0.75" in body # scope info: objective thread
|
||||
assert "3–18×" in body # magnification range, integral values un-padded
|
||||
assert "3-18" in body # magnification range, integral values un-padded
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_includes_objective_diameter(db_sessionmaker):
|
||||
async with db_sessionmaker() as db:
|
||||
ids = await _seed_guide_data(db)
|
||||
apn = AttachmentPointName(name="Objective")
|
||||
db.add(apn)
|
||||
await db.flush()
|
||||
db.add(
|
||||
AttachmentPoint(
|
||||
augmented_part_id=ids["s1"].id,
|
||||
attachment_point_name_id=apn.id,
|
||||
static_connection=StaticConnection(od_mm=50, od_in=1.9685),
|
||||
)
|
||||
)
|
||||
await db.commit()
|
||||
|
||||
guide = await scope_guide.build(db)
|
||||
|
||||
rows = {r["scope"].description: r for r in guide["rows"]}
|
||||
assert rows["Alpha 3-18x50"]["objective_diameter_mm"] == 50
|
||||
assert rows["Zeta 1-6x24"]["objective_diameter_mm"] is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scopes_page_renders_objective_diameter_in_magnification(
|
||||
client, seeded, make_user, db_sessionmaker
|
||||
):
|
||||
async with db_sessionmaker() as db:
|
||||
ids = await _seed_guide_data(db)
|
||||
apn = AttachmentPointName(name="Objective")
|
||||
db.add(apn)
|
||||
await db.flush()
|
||||
db.add(
|
||||
AttachmentPoint(
|
||||
augmented_part_id=ids["s1"].id,
|
||||
attachment_point_name_id=apn.id,
|
||||
static_connection=StaticConnection(od_mm=50, od_in=1.9685),
|
||||
)
|
||||
)
|
||||
await db.commit()
|
||||
await make_user("reader4@example.com", role_ids=[seeded["roles"]["user"].id])
|
||||
await _web_login(client, "reader4@example.com")
|
||||
resp = await client.get("/scopes")
|
||||
assert resp.status_code == 200
|
||||
assert "3-18x50" in resp.text
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in new issue
Block a user