Skip to content

Commit aab1a6b

Browse files
authored
Merge pull request #325 from EBI-G2P/fix_bug_pheno_summary_v13
Fix bug in phenotype summary
2 parents e3fda1c + 6a6aef2 commit aab1a6b

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

gene2phenotype_project/gene2phenotype_app/serializers/locus_genotype_disease.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def get_phenotype_summary(self, id: int) -> list[dict[str, Any]]:
261261
summary_text = summary_obj.summary
262262

263263
data[summary_text] = {
264-
"id": summary_text.id,
264+
"id": summary_obj.id,
265265
"summary": summary_text,
266266
"publication": summary_obj.publication.pmid,
267267
}

gene2phenotype_project/gene2phenotype_app/tests/views/test_locus_genotype_disease.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ class LocusGenotypeDiseaseDetailEndpoint(TestCase):
2929
"gene2phenotype_app/fixtures/lgd_publication.json",
3030
"gene2phenotype_app/fixtures/lgd_comment.json",
3131
"gene2phenotype_app/fixtures/lgd_phenotype.json",
32+
"gene2phenotype_app/fixtures/lgd_phenotype_summary.json",
3233
"gene2phenotype_app/fixtures/lgd_publication_comment.json",
3334
"gene2phenotype_app/fixtures/mined_publication.json",
3435
"gene2phenotype_app/fixtures/lgd_mined_publication.json",
3536
]
3637

3738
def setUp(self):
3839
self.url_list_lgd = reverse("lgd", kwargs={"stable_id": "G2P00001"})
40+
self.url_list_lgd_2 = reverse("lgd", kwargs={"stable_id": "G2P00002"})
3941
self.url_lgd_deleted = reverse("lgd", kwargs={"stable_id": "G2P00003"})
4042
self.url_lgd_invalid = reverse("lgd", kwargs={"stable_id": "G2P00000"})
4143
self.url_lgd_merged = reverse("lgd", kwargs={"stable_id": "G2P00007"})
@@ -233,4 +235,52 @@ def test_lgd_detail_authenticated(self):
233235
"score_comment": None,
234236
}
235237
]
236-
self.assertEqual(response.data["mined_publications"], expected_data_mined_publication)
238+
self.assertEqual(
239+
response.data["mined_publications"], expected_data_mined_publication
240+
)
241+
242+
def test_lgd_detail_authenticated_phenotypes(self):
243+
"""
244+
Test the locus genotype disease display for authenticated users.
245+
Check if phenotype summary is correctly displayed.
246+
"""
247+
# Login
248+
user = User.objects.get(email="user5@test.ac.uk")
249+
refresh = RefreshToken.for_user(user)
250+
access_token = str(refresh.access_token)
251+
252+
# Authenticate by setting cookie on the test client
253+
self.client.cookies[settings.SIMPLE_JWT["AUTH_COOKIE"]] = access_token
254+
255+
response = self.client.get(self.url_list_lgd_2)
256+
self.assertEqual(response.status_code, 200)
257+
258+
expected_data_phenotypes = [
259+
{
260+
"term": "Abnormality of connective tissue",
261+
"accession": "HP:0003549",
262+
"publications": [15214012],
263+
},
264+
{
265+
"term": "Abnormality of the musculoskeletal system",
266+
"accession": "HP:0033127",
267+
"publications": [15214012],
268+
},
269+
{
270+
"term": "Urinary tract neoplasm",
271+
"accession": "HP:0010786",
272+
"publications": [15214012],
273+
},
274+
]
275+
self.assertEqual(list(response.data["phenotypes"]), expected_data_phenotypes)
276+
277+
expected_phenotype_summary = [
278+
{
279+
"id": 1,
280+
"summary": "Abnormality of connective tissue and of the musculoskeletal system",
281+
"publication": 15214012,
282+
}
283+
]
284+
self.assertEqual(
285+
list(response.data["phenotype_summary"]), expected_phenotype_summary
286+
)

0 commit comments

Comments
 (0)