Making objective_lens a thing
This commit is contained in:
1 parent
fcb4dbaa62
commit
12e6984c63
17 files changed
+115
-119
No files matched your search
+11
-36
@@ -1,12 +1,9 @@
|
||||
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
|
||||
|
||||
@@ -34,7 +31,9 @@ async def _seed_guide_data(db):
|
||||
db.add(p)
|
||||
return p
|
||||
|
||||
s1 = part("Alpha 3-18x50", scope_t.id, manufacturer_id=10, sub_part_type_id=rifle.id)
|
||||
s1 = part(
|
||||
"Alpha 3-18x50", scope_t.id, manufacturer_id=10, sub_part_type_id=rifle.id
|
||||
)
|
||||
s2 = part("Zeta 1-6x24", scope_t.id, manufacturer_id=20, sub_part_type_id=reddot.id)
|
||||
fc1 = part("Flip cover 50mm", cover_t.id)
|
||||
a1 = part("ARD 50mm", ard_t.id)
|
||||
@@ -46,6 +45,7 @@ async def _seed_guide_data(db):
|
||||
augmented_part_id=s1.id,
|
||||
magnification_min=3,
|
||||
magnification_max=18,
|
||||
objective_lens_diameter_mm=50,
|
||||
objective_thread_pitch="M52x0.75",
|
||||
)
|
||||
)
|
||||
@@ -172,9 +172,7 @@ async def test_build_filters_by_required_fit_type(db_sessionmaker):
|
||||
|
||||
|
||||
async def _web_login(client, email, password="secret123"):
|
||||
resp = await client.post(
|
||||
"/login", data={"email": email, "password": password}
|
||||
)
|
||||
resp = await client.post("/login", data={"email": email, "password": password})
|
||||
assert resp.status_code == 303
|
||||
|
||||
|
||||
@@ -206,45 +204,22 @@ async def test_scopes_page_renders_rows_and_fits(
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_includes_objective_diameter(db_sessionmaker):
|
||||
async def test_build_includes_objective_lens_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()
|
||||
|
||||
await _seed_guide_data(db)
|
||||
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
|
||||
assert rows["Alpha 3-18x50"]["info"].objective_lens_diameter_mm == 50
|
||||
assert rows["Zeta 1-6x24"]["info"] is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scopes_page_renders_objective_diameter_in_magnification(
|
||||
async def test_scopes_page_renders_objective_lens_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 _seed_guide_data(db)
|
||||
await make_user("reader4@example.com", role_ids=[seeded["roles"]["user"].id])
|
||||
await _web_login(client, "reader4@example.com")
|
||||
resp = await client.get("/scopes")
|
||||
|
||||
Reference in new issue
Block a user