-
-
Notifications
You must be signed in to change notification settings - Fork 192
Update ideogram tests. #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
55c54fc
5cbfa6b
2a1a587
7d9ec7e
f8c394f
6431340
3d7b580
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ matplotlib | |
| numpy | ||
| pandas | ||
| parmed | ||
| plotly==3.5.0 | ||
| plotly>=3.5.0 | ||
| requests | ||
| scipy>=1.1.0 | ||
| scikit-learn | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import os | ||
| import json | ||
| import os | ||
|
|
||
| from pytest_dash.wait_for import ( | ||
| wait_for_element_by_css_selector, | ||
| wait_for_element_by_id, | ||
|
|
@@ -14,14 +15,12 @@ | |
| COMPONENT_REACT_BASE | ||
| ) | ||
|
|
||
| # TODO by merging https://github.com/plotly/dash-bio/pull/201 | ||
|
|
||
| # these tests are written for the locked version v1.4.1 | ||
| # NOTE These tests were written to work with dependency `ideogram` v1.4.1: | ||
| # git+https://github.com/eweitz/ideogram.git#7d9b2ab91b91ef35db93bdeb529d4760de63292f | ||
| # if the version in package-lock.json is different and some of the test fails it might be due | ||
| # to changes from the author of https://github.com/eweitz/ideogram. For example, currently in the | ||
| # version v1.5.1 test_orientation fails because "chromosome-set-container" was renamed to | ||
| # "chromosome-set" which result in a timeout of the _wait_for function | ||
| # This version is locked in `package-lock.json`. If that changed and some of the tests failed, | ||
| # it might be due to changes in https://github.com/eweitz/ideogram. For example, test_orientation | ||
| # fails with version v1.5.1 because "chromosome-set-container" was renamed to "chromosome-set" | ||
| # (which results in the wait_for function timing out without finding the element). | ||
|
|
||
| # define app name once | ||
| APP_NAME = os.path.basename(__file__).replace('test_', '').replace('.py', '').replace('_', '-') | ||
|
|
@@ -80,7 +79,7 @@ def ideogram_test_props_callback( | |
|
|
||
|
|
||
| def test_chr_height(dash_threaded): | ||
| """Test change maximal height of the chromosome.""" | ||
| """Test change of chromosome maximal height.""" | ||
|
|
||
| prop_type = 'float' | ||
|
|
||
|
|
@@ -227,16 +226,16 @@ def assert_callback(prop_value, nclicks, input_value): | |
| driver = dash_threaded.driver | ||
|
|
||
| # assert 22 chromosomes + X and Y chromosomes | ||
| num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome')) | ||
| assert num_chromosoms == 24 | ||
| chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a particular reason that you changed these? (I'm just wondering if it somehow speeds things up, or ensures that we have a result before trying to test the assertion)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is to standardize the tests?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For both reasons: standardize and get elements before taking their length (for possible debugging too). |
||
| assert len(chromosomes) == 24 | ||
|
|
||
| # trigger a change of the component prop | ||
| btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) | ||
| btn.click() | ||
|
|
||
| # assert doubling of the 22 chromosomes + X and Y chromosomes | ||
| num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome')) | ||
| assert num_chromosoms == 46 | ||
| chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome') | ||
| assert len(chromosomes) == 46 | ||
|
|
||
|
|
||
| def test_chromosomes(dash_threaded): | ||
|
|
@@ -266,13 +265,17 @@ def assert_callback(prop_value, nclicks, input_value): | |
|
|
||
| driver = dash_threaded.driver | ||
|
|
||
| # assert 22 chromosomes + X and Y chromosomes | ||
| chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome') | ||
| assert len(chromosomes) == 24 | ||
|
|
||
| # trigger a change of the component prop | ||
| btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) | ||
| btn.click() | ||
|
|
||
| # assert the set of chromosomes contains 3 chromosomes | ||
| num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome')) | ||
| assert num_chromosoms == 3 | ||
| chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome') | ||
| assert len(chromosomes) == 3 | ||
|
|
||
|
|
||
| def test_chromosomes_wrong_input(dash_threaded): | ||
|
|
@@ -302,13 +305,17 @@ def assert_callback(prop_value, nclicks, input_value): | |
|
|
||
| driver = dash_threaded.driver | ||
|
|
||
| # assert 22 chromosomes + X and Y chromosomes | ||
| chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome') | ||
| assert len(chromosomes) == 24 | ||
|
|
||
| # trigger a change of the component prop | ||
| btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) | ||
| btn.click() | ||
|
|
||
| # assert the set of chromosomes contains 2 chromosomes | ||
| num_chromosoms = len(wait_for_elements_by_css_selector(driver, '.chromosome')) | ||
| assert num_chromosoms == 2 | ||
| chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome') | ||
| assert len(chromosomes) == 2 | ||
|
|
||
|
|
||
| def test_brush(dash_threaded): | ||
|
|
@@ -396,7 +403,7 @@ def assert_callback(prop_value, nclicks, input_value): | |
|
|
||
| # assert the presence of bands' labels | ||
| labels = driver.find_elements_by_class_name('bandLabel') | ||
| assert len(labels) != 0 | ||
| assert len(labels) > 0 | ||
|
|
||
|
|
||
| def test_show_chromosome_labels(dash_threaded): | ||
|
|
@@ -435,8 +442,8 @@ def assert_callback(prop_value, nclicks, input_value): | |
| btn.click() | ||
|
|
||
| # assert the presence of chromosomes' labels | ||
| num_labels = len(wait_for_elements_by_css_selector(driver, '.chrLabel')) | ||
| assert num_labels != 0 | ||
| labels = wait_for_elements_by_css_selector(driver, '.chrLabel') | ||
| assert len(labels) > 0 | ||
|
|
||
|
|
||
| def test_sex(dash_threaded): | ||
|
|
@@ -629,7 +636,7 @@ def assert_callback(prop_value, nclicks, input_value): | |
|
|
||
| # assert the presence of homology region | ||
| regions = wait_for_elements_by_css_selector(driver, '.syntenicRegion') | ||
| assert len(regions) != 0 | ||
| assert len(regions) > 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this changed? I guess it makes sense, since the length of a list cannot be negative, but I'm not sure this change affects performance or functionality. (Correct me if I'm wrong!)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't affect performance or functionality, but if ever a length was negative, I would want to catch it!! Well, I'm for writing the meaningful version directly (we expect this length to be positive, so let's write it, it's easier on the reader too). |
||
|
|
||
|
|
||
| def test_full_chromosome_labels(dash_threaded): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Words like these make me remember why I switched my major from biochem 🤣