From 55c54fc5a909b77385fd6f0b337586da4b72935e Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Mon, 25 Mar 2019 14:54:33 +0100 Subject: [PATCH 1/5] Proofread Ideogram test file --- tests/test_ideogram.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/test_ideogram.py b/tests/test_ideogram.py index 0771d165b..041cf1350 100644 --- a/tests/test_ideogram.py +++ b/tests/test_ideogram.py @@ -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 a timeout of the _wait_for function). # 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' From 2a1a5875217de749bb9cd913017c137e736b76fa Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Mon, 25 Mar 2019 17:19:48 +0100 Subject: [PATCH 2/5] Correct word about ploidy --- src/lib/components/Ideogram.react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/Ideogram.react.js b/src/lib/components/Ideogram.react.js index 2df7e2613..d21748ce5 100644 --- a/src/lib/components/Ideogram.react.js +++ b/src/lib/components/Ideogram.react.js @@ -8,7 +8,7 @@ import {omit} from 'ramda'; * datasets for organisms such as human, mouse, and any other * eukaryote. The Ideogram component can be used to compare * homologous features between chromosomes, and depict - * haploid, diploid, aneuploidy genomes. It can also display + * haploid, diploid, aneuploid genomes. It can also display * annotations on genomic data using histograms and overlays. * * Reference: https://eweitz.github.io/ideogram/ From 7d9ec7efdb85ed16cf5c4b8009447008b21a417a Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Mon, 25 Mar 2019 17:20:49 +0100 Subject: [PATCH 3/5] Let plotly.py dependency update --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3e5405804..40192dc98 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,7 @@ matplotlib numpy pandas parmed -plotly==3.5.0 +plotly>=3.5.0 requests scipy>=1.1.0 scikit-learn From f8c394f25a0a132fa8de1eabfef47061602eb4ea Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Mon, 25 Mar 2019 17:30:16 +0100 Subject: [PATCH 4/5] Check former number of chromosomes --- tests/test_ideogram.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_ideogram.py b/tests/test_ideogram.py index 041cf1350..5cae3cd4c 100644 --- a/tests/test_ideogram.py +++ b/tests/test_ideogram.py @@ -265,6 +265,10 @@ 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 + # trigger a change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() @@ -301,6 +305,10 @@ 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 + # trigger a change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() From 3d7b580c7f3b797d8b3fff0895b9ea03ab07819e Mon Sep 17 00:00:00 2001 From: Marianne Corvellec Date: Thu, 28 Mar 2019 19:33:23 +0100 Subject: [PATCH 5/5] Give Ideogram tests similar style / structure --- tests/test_ideogram.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/test_ideogram.py b/tests/test_ideogram.py index 5cae3cd4c..c411758a0 100644 --- a/tests/test_ideogram.py +++ b/tests/test_ideogram.py @@ -20,7 +20,7 @@ # 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 a timeout of the _wait_for function). +# (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('_', '-') @@ -226,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') + 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,16 +266,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') + 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): @@ -306,16 +306,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') + 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): @@ -403,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): @@ -442,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): @@ -636,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 def test_full_chromosome_labels(dash_threaded):