|
1 | 1 | # ruff: noqa: E402 |
2 | 2 |
|
3 | 3 | import os |
4 | | -import pytest |
5 | | -import requests |
6 | 4 | from datetime import datetime |
7 | | -from unittest.mock import patch, MagicMock |
| 5 | +from unittest.mock import MagicMock, patch |
8 | 6 | from urllib import parse |
9 | 7 |
|
| 8 | +import pytest |
| 9 | +import requests |
| 10 | + |
10 | 11 | arq = pytest.importorskip("arq") |
11 | 12 | cdot = pytest.importorskip("cdot") |
12 | 13 | fastapi = pytest.importorskip("fastapi") |
13 | 14 |
|
14 | | -from mavedb.lib.clingen.constants import LDH_MAVE_ACCESS_ENDPOINT, GENBOREE_ACCOUNT_NAME, GENBOREE_ACCOUNT_PASSWORD |
15 | | -from mavedb.lib.utils import batched |
| 15 | +from mavedb.lib.clingen.constants import GENBOREE_ACCOUNT_NAME, GENBOREE_ACCOUNT_PASSWORD, LDH_MAVE_ACCESS_ENDPOINT |
16 | 16 | from mavedb.lib.clingen.services import ( |
17 | 17 | ClinGenAlleleRegistryService, |
18 | 18 | ClinGenLdhService, |
19 | | - get_clingen_variation, |
20 | 19 | clingen_allele_id_from_ldh_variation, |
21 | 20 | get_allele_registry_associations, |
| 21 | + get_clingen_variation, |
22 | 22 | ) |
23 | | - |
| 23 | +from mavedb.lib.utils import batched |
24 | 24 | from tests.helpers.constants import VALID_CLINGEN_CA_ID |
25 | 25 |
|
26 | 26 | TEST_CLINGEN_URL = "https://pytest.clingen.com" |
@@ -365,3 +365,46 @@ def test_get_allele_registry_associations_no_match(): |
365 | 365 | ] |
366 | 366 | result = get_allele_registry_associations(content_submissions, submission_response) |
367 | 367 | assert result == {} |
| 368 | + |
| 369 | + |
| 370 | +def test_get_allele_registry_associations_with_errors(caplog): |
| 371 | + content_submissions = ["NM_0001:c.1A>G", "NM_0002:c.2T>C"] |
| 372 | + submission_response = [ |
| 373 | + { |
| 374 | + "errorType": "InvalidHGVS", |
| 375 | + "hgvs": "NM_0001:c.1A>G", |
| 376 | + "message": "The HGVS string is invalid.", |
| 377 | + }, |
| 378 | + { |
| 379 | + "@id": "http://reg.test.genome.network/allele/CA456", |
| 380 | + "genomicAlleles": [], |
| 381 | + "transcriptAlleles": [{"hgvs": "NM_0002:c.2T>C"}], |
| 382 | + }, |
| 383 | + ] |
| 384 | + |
| 385 | + result = get_allele_registry_associations(content_submissions, submission_response) |
| 386 | + assert result == {} |
| 387 | + |
| 388 | + |
| 389 | +def test_get_allele_registry_associations_mixed(): |
| 390 | + content_submissions = ["NM_0001:c.1A>G", "NM_0002:c.2T>C", "NM_0003:c.3G>A"] |
| 391 | + submission_response = [ |
| 392 | + { |
| 393 | + "@id": "http://reg.test.genome.network/allele/CA123", |
| 394 | + "genomicAlleles": [{"hgvs": "NM_0001:c.1A>G"}], |
| 395 | + "transcriptAlleles": [], |
| 396 | + }, |
| 397 | + { |
| 398 | + "errorType": "InvalidHGVS", |
| 399 | + "hgvs": "NM_0002:c.2T>C", |
| 400 | + "message": "The HGVS string is invalid.", |
| 401 | + }, |
| 402 | + { |
| 403 | + "@id": "http://reg.test.genome.network/allele/CA789", |
| 404 | + "genomicAlleles": [], |
| 405 | + "transcriptAlleles": [{"hgvs": "NM_0003:c.3G>A"}], |
| 406 | + }, |
| 407 | + ] |
| 408 | + |
| 409 | + result = get_allele_registry_associations(content_submissions, submission_response) |
| 410 | + assert result == {"NM_0001:c.1A>G": "CA123", "NM_0003:c.3G>A": "CA789"} |
0 commit comments