def test_sex(dash_threaded): """Test the hiding of chromosome Y if sex is set to female.""" prop_type = 'str' def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: answer = FAIL if PROP_TYPES[prop_type](input_value) == prop_value: answer = PASS return answer template_test_component(dash_threaded, APP_NAME, assert_callback, ideogram_test_props_callback, 'sex', 'female', prop_type=prop_type, component_base=COMPONENT_REACT_BASE, **BASIC_PROPS) driver = dash_threaded.driver # assert the presence of the chromosome Y chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome') num_chromosoms = len(chromosomes) assert num_chromosoms == 24 has_chr_y = False for chromosome in chromosomes: if 'chrY' in chromosome.get_attribute('id'): has_chr_y = True assert has_chr_y is True # trigger a change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() # assert the absence of the chromosome Y chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome', timeout=20) num_chromosoms = len(chromosomes) assert num_chromosoms == 23 has_chr_y = False for chromosome in chromosomes: if 'chrY' in chromosome.get_attribute('id'): has_chr_y = True assert has_chr_y is False
def test_showlegend(dash_threaded): """Test the legend display.""" def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: if PROP_TYPES['bool'](input_value) == prop_value: answer = PASS return answer template_test_component( dash_threaded, APP_NAME, assert_callback, oncoprint_props_callback, 'showlegend', 'False', prop_type='bool', component_base=COMPONENT_REACT_BASE, data=TEST_DATA ) driver = dash_threaded.driver # assert there is a legend (bar) legend = wait_for_elements_by_css_selector(driver, 'g.traces') assert len(legend) != 0 # trigger change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() # assert there is no more legend (bar) legend = driver.find_elements_by_class_name('legendbar') assert len(legend) == 0
def test_orientation(dash_threaded): """Test orientation prop.""" prop_type = 'str' def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: answer = FAIL if PROP_TYPES[prop_type](input_value) == prop_value: answer = PASS return answer template_test_component(dash_threaded, APP_NAME, assert_callback, ideogram_test_props_callback, 'orientation', 'horizontal', prop_type=prop_type, component_base=COMPONENT_REACT_BASE, **BASIC_PROPS) driver = dash_threaded.driver # assert presence of chromosomes' rotation chromosoms = wait_for_elements_by_css_selector( driver, '.chromosome-set-container') for chromosom in chromosoms: assert 'rotate(90)' in str(chromosom.get_attribute('transform')) # trigger a change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() # assert absence of chromosomes' rotation chromosoms = wait_for_elements_by_css_selector( driver, '.chromosome-set-container') for chromosom in chromosoms: assert 'rotate(90)' not in str(chromosom.get_attribute('transform'))
def test_homology(dash_threaded): """Test the display of a basic homology""" prop_type = 'dict' prop_val = { "chrOne": { "organism": "9606", "start": [10001, 105101383], "stop": [27814790, 156030895], }, "chrTwo": { "organism": "9606", "start": [3000000, 125101383], "stop": [9000000, 196130895], }, } def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: answer = FAIL if PROP_TYPES[prop_type](input_value) == prop_value: answer = PASS return answer template_test_component( dash_threaded, APP_NAME, assert_callback, ideogram_test_props_callback, 'homology', json.dumps(prop_val), prop_type=prop_type, component_base=COMPONENT_REACT_BASE, perspective="comparative", chromosomes=["1", "2"], **BASIC_PROPS ) driver = dash_threaded.driver # assert the absence of homology region regions = driver.find_elements_by_class_name('syntenicRegion') assert len(regions) == 0 # trigger a change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() # assert the presence of homology region regions = wait_for_elements_by_css_selector(driver, '.syntenicRegion', timeout=20) assert len(regions) > 0
def test_full_chromosome_labels(dash_threaded): """Test the full chromosome label display/hiding""" prop_type = 'bool' def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: answer = FAIL if PROP_TYPES[prop_type](input_value) == prop_value: answer = PASS return answer template_test_component( dash_threaded, APP_NAME, assert_callback, ideogram_test_props_callback, 'fullChromosomeLabels', 'True', prop_type=prop_type, component_base=COMPONENT_REACT_BASE, chromosomes=['1'], fullChromosomeLabels=False, **BASIC_PROPS ) driver = dash_threaded.driver # assert the absence of a full label regions = wait_for_elements_by_css_selector(driver, 'tspan') assert len(regions) == 1 # trigger a change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() # assert the presence of a full label regions = wait_for_elements_by_css_selector(driver, 'tspan', timeout=20) assert len(regions) == 2
def test_chromosomes_wrong_input(dash_threaded): """Test input of a wrong chromosome name.""" prop_type = 'list' def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: answer = FAIL if PROP_TYPES[prop_type](input_value) == prop_value: answer = PASS return answer template_test_component(dash_threaded, APP_NAME, assert_callback, ideogram_test_props_callback, 'chromosomes', '1,D,3', prop_type=prop_type, component_base=COMPONENT_REACT_BASE, **BASIC_PROPS) 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 chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome', timeout=20) assert len(chromosomes) == 2
def test_ploidy(dash_threaded): """Test duplication of each chromosome.""" prop_type = 'int' def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: answer = FAIL if PROP_TYPES[prop_type](input_value) == prop_value: answer = PASS return answer template_test_component(dash_threaded, APP_NAME, assert_callback, ideogram_test_props_callback, 'ploidy', '2', prop_type=prop_type, component_base=COMPONENT_REACT_BASE, **BASIC_PROPS) 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 doubling of the 22 chromosomes + X and Y chromosomes chromosomes = wait_for_elements_by_css_selector(driver, '.chromosome', timeout=20) assert len(chromosomes) == 46
def test_show_chromosome_labels(dash_threaded): """Test the display/hiding of chromosomes labels.""" prop_type = 'bool' def assert_callback(prop_value, nclicks, input_value): answer = '' if nclicks is not None: answer = FAIL if PROP_TYPES[prop_type](input_value) == prop_value: answer = PASS return answer template_test_component( dash_threaded, APP_NAME, assert_callback, ideogram_test_props_callback, 'showChromosomeLabels', 'True', prop_type=prop_type, component_base=COMPONENT_REACT_BASE, **BASIC_PROPS ) driver = dash_threaded.driver # assert the absence of chromosomes' labels labels = driver.find_elements_by_class_name('chrLabel') assert len(labels) == 0 # trigger a change of the component prop btn = wait_for_element_by_css_selector(driver, '#test-{}-btn'.format(APP_NAME)) btn.click() # assert the presence of chromosomes' labels labels = wait_for_elements_by_css_selector(driver, '.chrLabel', timeout=20) assert len(labels) > 0
def elements_selector(self, selector): return wait_for_elements_by_css_selector(self.driver, selector[2:-1])