Skip to content

Commit

Permalink
added more tests and refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed May 3, 2024
1 parent dd533fa commit 99b1e95
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 144 deletions.
2 changes: 2 additions & 0 deletions resources/update_database/update_database_9.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
ALTER TABLE `HerediVar_ahdoebm1`.`annotation_queue`
CHANGE COLUMN `status` `status` ENUM('pending', 'success', 'error', 'retry', 'aborted', 'progress') NOT NULL DEFAULT 'pending' ;

UPDATE HerediVar_ahdoebm1.annotation_type SET is_deleted = 1 WHERE title = "maxentscan_ref" OR title = "maxentscan_alt";
2 changes: 1 addition & 1 deletion src/frontend_celery/playwright/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def page(browser):
utils.screenshot(page)


@pytest.fixture(autouse=True)
@pytest.fixture(autouse=False)
def _rollback():
yield
utils.execute_sql_script("/mnt/storage2/users/ahdoebm1/HerediVar/src/frontend_celery/playwright/data/truncate.sql")
Expand Down
2 changes: 1 addition & 1 deletion src/frontend_celery/playwright/start_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fi
cd $TESTDIR
export TESTUSER=$TEST_READONLY
export TESTUSERPW=$TEST_READONLY_PW
pytest --screenshot=only-on-failure --browser firefox tests/read_only/ -k 'test_varaint_details_access' #-k 'test_dev' --browser webkit --browser chromium --numprocesses 2
pytest --screenshot=only-on-failure --browser firefox tests/read_only/ -k 'test_variant_details_consequences' #-k 'test_dev' --browser webkit --browser chromium --numprocesses 2

# stop services
#pkill -s 0 -e java
Expand Down
263 changes: 263 additions & 0 deletions src/frontend_celery/playwright/tests/read_only/test_variant_details.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/frontend_celery/playwright/update_static_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ echo $path_to_structure
echo $path_to_data


static_data_tables="annotation_type classification_scheme classification_criterium classification_criterium_strength classification_scheme_alias mutually_exclusive_criteria mutually_inclusive_criteria user"
static_data_tables="annotation_type classification_scheme classification_criterium classification_criterium_strength classification_scheme_alias mutually_exclusive_criteria mutually_inclusive_criteria user heredicare_ZID"


# dump structure
Expand Down
25 changes: 24 additions & 1 deletion src/frontend_celery/playwright/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
sys.path.append(path.dirname(path.dirname(path.dirname(path.dirname(path.abspath(__file__))))))
import common.functions as functions
from subprocess import Popen, PIPE, STDOUT

import requests

GOOD_STATI=[200, 302, 304]
ERROR_STATI=[500, 302, 304]
Expand Down Expand Up @@ -86,6 +86,29 @@ def nav(meth, expected_stati, *args, **kwargs):
assert response.status in expected_stati, f"{response.request.method} {response.url} returned {response.status}"




def check_all_links(page):
# check external links
locator = page.locator(".external_link")
nlinks = locator.count()
for i in range(1, nlinks+1): # idk why it is not possible to iterate over the locator which matches multiple elements. Thus, we do this shiz
url = page.locator(":nth-match(.external_link, " + str(i) + ")").get_attribute("uri")
resp = requests.get(url)
assert resp.status_code in GOOD_STATI, "The external link " + url + " returned status code " + resp.status_code

# check standard href links
base_url = get_base_url(page)
link_handles = page.locator("[href]")
for handle in link_handles.element_handles():
link = handle.get_attribute('href')
if link == '#':
continue
if not link.startswith("http"):
link = base_url.strip('/') + link
resp = requests.get(link)
assert resp.status_code in GOOD_STATI, "The href powered link " + link + " returned status code " + resp.status_code

#import json
#def test(route, post_data):
# post_data = json.dumps(post_data)
Expand Down
221 changes: 82 additions & 139 deletions src/frontend_celery/webapp/templates/macros.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ <h4 class="card-subcaption">ClinVar classifications</h4>
{% if variant.annotations.brca_exchange_clinical_significance is not none %}
<div class="ssb">
<h4 class="card-subcaption">BRCA exchange classification</h4>
<div class="ssl">
<div class="ssl" data-testid="annotation-{{variant.annotations.brca_exchange_clinical_significance.title}}">
{{variant.annotations.brca_exchange_clinical_significance.value}}
</div>
</div>
Expand Down

0 comments on commit 99b1e95

Please sign in to comment.