Skip to content

Commit

Permalink
Merge branch 'show_mane_on_variant_summary' of https://github.com/Cli…
Browse files Browse the repository at this point in the history
…nical-Genomics/scout into show_mane_on_variant_summary
  • Loading branch information
Chiara Rasi committed Mar 5, 2024
2 parents c1e34dd + 6c0f22d commit 1d54602
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)
- In the diagnoses page genes associated with a disease are displayed using hgnc symbol instead of hgnc id
- Refactor view route to allow navigation directly to unique variant document id, improve permissions check
- Do not show MANE and MANE Plus Clinical transcripts annotated from VEP (saved in variants)but collect this info from the transcripts database collection
- Refactor view route to allow navigation directly to unique case id (in particular for gens)
### Fixed
- Refactored code in cases blueprints and variant_events adapter (set diseases for partial causative variants) to use "disease" instead of "omim" to encompass also ORPHA terms
- Refactored code in `scout/parse/omim.py` and `scout/parse/disease_terms.py` to use "disease" instead of "phenotype" to differentiate from HPO terms
Expand Down
24 changes: 22 additions & 2 deletions scout/server/blueprints/cases/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,29 @@ def index():


@cases_bp.route("/<institute_id>/<case_name>")
@cases_bp.route("/case/case_id/<case_id>")
@templated("cases/case.html")
def case(institute_id, case_name):
"""Display one case."""
def case(
case_name: Optional[str] = None,
institute_id: Optional[str] = None,
case_id: Optional[str] = None,
):
"""Display one case.
Institute and display_name pairs uniquely specify a case.
So do case_id, but we still call institute_and_case again to fetch institute
and reuse its user access verification.
"""

if case_id:
case_obj = store.case(case_id=case_id, projection={"display_name": 1, "owner": 1})

if not case_obj:
flash("Case {} does not exist in database!".format(case_id))
return abort(404)

case_name = case_obj.get("display_name")
institute_id = case_obj.get("owner")

institute_obj, case_obj = institute_and_case(store, institute_id, case_name)
if not case_obj:
flash("Case {} does not exist in database!".format(case_name))
Expand Down
24 changes: 23 additions & 1 deletion tests/server/blueprints/cases/test_cases_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def test_case_custom_images(app, institute_obj, case_obj):
with app.test_client() as client:
# GIVEN that the user could be logged in
resp = client.get(url_for("auto_login"))
assert resp.status_code == 200

# WHEN case page is loaded
resp = client.get(
Expand All @@ -365,6 +366,26 @@ def test_case_custom_images(app, institute_obj, case_obj):
assert bytes(f"{section_name}-accordion", "utf-8") in dta


def test_case_by_id(app, case_obj):
"""Test that cases can be retrieved using case_id only"""
# GIVEN an initialized app
with app.test_client() as client:
# GIVEN that the user could be logged in
resp = client.get(url_for("auto_login"))
assert resp.status_code == 200

# WHEN case page is loaded
resp = client.get(
url_for(
"cases.case",
case_id=case_obj["_id"],
)
)

# THEN it should return a valid page
assert resp.status_code == 200


def test_case_outdated_panel(app, institute_obj, case_obj):
"""Test case displaying an outdated panel warning badge"""

Expand All @@ -385,6 +406,7 @@ def test_case_outdated_panel(app, institute_obj, case_obj):
with app.test_client() as client:
# GIVEN that the user could be logged in
resp = client.get(url_for("auto_login"))
assert resp.status_code == 200

# WHEN case page is loaded
resp = client.get(
Expand Down Expand Up @@ -423,7 +445,7 @@ def test_case_sma(app, case_obj, institute_obj):
assert resp.status_code == 200


def test_case_fusion(app, adapter, fusion_case_obj, institute_obj):
def test_case_fusion(app, fusion_case_obj, institute_obj):
"""Test the RNA fusion case page."""

# GIVEN an initialized app
Expand Down

0 comments on commit 1d54602

Please sign in to comment.