Ejemplo n.º 1
0
def setup_long_callback_app(manager_name, app_name):
    if manager_name == "celery":
        os.environ["LONG_CALLBACK_MANAGER"] = "celery"
        redis_url = os.environ["REDIS_URL"].rstrip("/")
        os.environ["CELERY_BROKER"] = f"{redis_url}/0"
        os.environ["CELERY_BACKEND"] = f"{redis_url}/1"

        # Clear redis of cached values
        redis_conn = redis.Redis(host="localhost", port=6379, db=1)
        cache_keys = redis_conn.keys()
        if cache_keys:
            redis_conn.delete(*cache_keys)

        worker = subprocess.Popen(
            [
                "celery",
                "-A",
                f"tests.integration.long_callback.{app_name}:handle",
                "worker",
                "-P",
                "prefork",
                "--concurrency",
                "2",
                "--loglevel=info",
            ],
            preexec_fn=os.setpgrp,
        )
        try:
            yield import_app(f"tests.integration.long_callback.{app_name}")
        finally:
            # Interval may run one more time after settling on final app state
            # Sleep for 1 interval of time
            time.sleep(0.5)
            os.environ.pop("LONG_CALLBACK_MANAGER")
            os.environ.pop("CELERY_BROKER")
            os.environ.pop("CELERY_BACKEND")
            kill(worker.pid)

    elif manager_name == "diskcache":
        os.environ["LONG_CALLBACK_MANAGER"] = "diskcache"
        cache_directory = tempfile.mkdtemp(prefix="lc-diskcache-")
        print(cache_directory)
        os.environ["DISKCACHE_DIR"] = cache_directory
        try:
            yield import_app(f"tests.integration.long_callback.{app_name}")
        finally:
            # Interval may run one more time after settling on final app state
            # Sleep for a couple of intervals
            time.sleep(2.0)
            shutil.rmtree(cache_directory, ignore_errors=True)
            os.environ.pop("LONG_CALLBACK_MANAGER")
            os.environ.pop("DISKCACHE_DIR")
Ejemplo n.º 2
0
 def test_fn(dash_duo):
     app = import_app(name)
     dash_duo.start_server(app)
     dash_duo.wait_for_element("canvas", timeout=30)
     time.sleep(sleep)
     take_snapshot(dash_duo, name.replace("demos.", ""))
     dash_duo.percy_snapshot(name)
Ejemplo n.º 3
0
def test_render_component(dash_duo):
    # Start a dash app contained as the variable `app` in `usage.py`
    app = import_app('usage')
    dash_duo.start_server(app)

    message = 'Hello from dash_mqtt'

    # Get the generated component input with selenium
    # The html input will be a children of the #input dash component
    my_input_component = dash_duo.find_element('#message_to_send')

    # Clear the input
    dash_duo.clear_input(my_input_component)

    # Send keys to the custom input.
    my_input_component.send_keys(message)

    # Get the send button input with selenium
    my_send_btn_component = dash_duo.find_element('#send')

    # Clear the input
    dash_duo.clear_input(my_input_component)

    # Send keys to the custom input.
    my_input_component.send_keys('Hello from dash_mqtt')

    # click send button
    dash_duo.multiple_click(my_send_btn_component, 1)

    # Wait for the text to equal, if after the timeout (default 10 seconds)
    # the text is not equal it will fail the test.
    dash_duo.wait_for_text_to_equal('#return_message', message)
Ejemplo n.º 4
0
def test_demo_component(dash_duo):
    # Start a dash app contained as the variable `app` in `usage.py`
    app = import_app('demo')

    dash_duo.start_server(app)

    dash_duo.wait_for_text_to_equal('#list-output', "List value : ['RM']", 60)
Ejemplo n.º 5
0
def test_two(dash_duo):
    app = import_app("app")
    dash_duo.start_server(app)

    #link1 = "http://192.168.1.170:5200/"
    #dash_duo.wait_for_page(url=link1)
    #dash_duo.take_snapshot("map1")

    #map = dash_duo.find_element("#map")
    #dash_duo.wait_for_text_to_equal("h1", "Hello Dash", timeout=4)
    #dash_duo.wait_for_element_by_id("map", timeout=10)

    #print("\nFound map",map)

    #dash_duo.click_at_coord_fractions(map, 0.75, 0.5)

    #items = str(app.layout).split(",")
    #links = [x for x in items if x.startswith(" href='/link")]
    #for rawlink in links:
    #    href = re.findall(r"'(.*?)'", rawlink)
    #    link = "http://127.0.0.1:8050"+href[0]
    #    print("Loading",link)
    #    dash_duo.wait_for_page(url=link)
    #    print("Loaded",link)

    #assert len(dash_duo.find_elements('map')) > 0
    #dash_duo.take_snapshot("test_two")
    #dash_duo.percy_snapshot("test_one")

    assert dash_duo.get_logs() == [], "browser console should contain no error"
Ejemplo n.º 6
0
def wetterdienst_ui(dash_tre):

    # Import Dash application in testing mode.
    app = import_app("wetterdienst.ui.explorer.app")

    # Start testing server and wait until page is loaded.
    dash_tre.start_server(app)
    dash_tre.wait_for_page(timeout=10)
Ejemplo n.º 7
0
def test_render_component(dash_duo):
    # Start a dash app contained as the variable `app` in `usage.py`
    app = import_app('usage')
    dash_duo.start_server(app)

    # Get the generated component input with selenium
    # The html input will be a children of the #input dash component
    my_component = dash_duo.find_element('button')

    assert 'Stop the ticking! Now' == my_component.get_attribute('innerHTML')
def test_upload_following(dash_duo):
	app = import_app("app")
	dash_duo.start_server(app)
	dash_duo.wait_for_text_to_equal("#corpus-select-title", "Use an existing corpus", timeout=4)
	
	corpus = dash_duo.driver.find_element_by_id('index-choose_corpus')
	dash_duo.multiple_click(corpus, 1)
	opt = dash_duo.find_element('#index-choose_corpus > div > div > div:nth-child(2) > div > div > div > div > div:nth-child(2)')
	dash_duo.multiple_click(opt, 1)
	dash_duo.wait_for_text_to_equal("#react-select-2--value-item", "sample_data_test_upload", timeout=3)
Ejemplo n.º 9
0
def test_rere001_h1_text_equals(dash_duo):
    """
    GIVEN the app is running
    WHEN the home page is available
    THEN the H1 heading element should include the text 'Waste and recycling' (not case sensitive)
    """
    app = import_app(app_file='apps.recycle_app.recycle_app')
    dash_duo.start_server(app)
    dash_duo.wait_for_element("h1", timeout=4)
    h1_text = dash_duo.find_element("h1").text
    assert h1_text.casefold() == 'Waste and recycling'.casefold()
Ejemplo n.º 10
0
def test_mayor_app(dash_duo):
    app = import_app("mayor")
    # app.layout = html.Div(id="nully-wrapper", children=0)

    dash_duo.start_server(app)

    candidates_row = dash_duo.find_element("#candidates-row")

    candidates = dash_duo.find_elements(".candidate")

    assert len(candidates) == 4
Ejemplo n.º 11
0
def test_rere002_dropdown_default(dash_duo):
    """
    GIVEN the app is running
    WHEN the dropdown selector on the home page is located
    THEN the value of the default selection should be 'London'
    """
    app = import_app(app_file='apps.recycle_app.recycle_app')
    dash_duo.start_server(app)
    dash_duo.wait_for_element("h1", timeout=4)
    WebDriverWait(dash_duo.driver, 3)
    assert 'London' in dash_duo.find_element("#area-select").text, "'London' should appear in the area dropdown"
Ejemplo n.º 12
0
def test_render_component(dash_duo):
    # Start a dash app contained as the variable `app` in `usage.py`
    app = import_app('usage')

    dash_duo.start_server(app)

    dash_duo.wait_for_text_to_equal('#output', 'Captcha Status initialize', 10)

    dash_duo.start_server(app)
    # dash_duo.find_element('#output').children = "Please Reload"

    dash_duo.wait_for_text_to_equal('#output', 'Captcha Status Pass', 60)
Ejemplo n.º 13
0
def test_002_employed_officer(dash_duo):
    app = import_app("app")
    dash_duo.start_server(app)
    # close out of modal disclaimer
    dash_duo.multiple_click("#disclaimer_btn", 1)
    dash_duo.multiple_click("#close", 1)
    time.sleep(0.5)
    inputbox = dash_duo.find_element("#officer_input")
    dash_duo.find_element("#data_html")
    inputbox.send_keys("Taylor, Heather\n")
    dash_duo.multiple_click("#submit", 1)
    dash_duo.wait_for_contains_text("#officer_name", "Taylor")
    dash_duo.wait_for_contains_text("#officer-info", "DSN:")
def test_reload(dash_duo):
	app = import_app("app")
	dash_duo.start_server(app)
	dash_duo.wait_for_text_to_equal("#corpus-select-title", "Use an existing corpus", timeout=4)
	
	#---test to choose the pre-installed sample data---
	# choose corpus "sample_data"
	corpus = dash_duo.driver.find_element_by_id('index-choose_corpus')
	dash_duo.multiple_click(corpus, 1)
	opt = dash_duo.driver.find_element_by_id('react-select-2--list')
	dash_duo.multiple_click(opt, 1)
	dash_duo.wait_for_text_to_equal("#react-select-2--value-item", "sample_data", timeout=3)

	# choose the analysis saved in previous test case
	analysis_dropdown = dash_duo.find_element('#save-select-dropdown')
	dash_duo.multiple_click(analysis_dropdown, 1)
	pre_saved = dash_duo.find_element('#save-select-dropdown > div > div:nth-child(2) > div > div > div > div > div:nth-child(2)')
	dash_duo.multiple_click(pre_saved, 1)

	# its name should be "test save"
	saved_analysis = dash_duo.driver.find_element_by_id('index-choose-save')
	dash_duo.wait_for_text_to_equal("#react-select-3--value-item", "[ test save ]", timeout=3)

	#start
	start = dash_duo.driver.find_element_by_id("start-exp")
	dash_duo.multiple_click(start, 1)

	time.sleep(1)

	# test year range
	year_from = dash_duo.find_element("#year-from > Div > span > input")
	year_to = dash_duo.find_element("#year-to > Div > span > input")
	assert '2013' == year_from.get_attribute('value')
	assert '2018' == year_to.get_attribute('value')

	#test base term
	base_term = dash_duo.driver.find_element_by_id("base-term")
	assert 'marriage' == base_term.get_attribute('value')

	#test if query terms are saved
	sent_tab = dash_duo.driver.find_element_by_id("Specs-tab")
	dash_duo.multiple_click(sent_tab, 1)
	time.sleep(1)
	current_query = dash_duo.driver.find_element_by_id("current_query")
	assert "equality | same sex | couples | marriage" == current_query.text

 	#test if groups are saved (here just test the first one)
	group_tab = dash_duo.driver.find_element_by_id("Group-tab")
	dash_duo.multiple_click(group_tab, 1)
	time.sleep(1)
	assert "test group" == dash_duo.find_element("#make-groups > div > input").get_attribute('value')
def test_delete(dash_duo):
	app = import_app("app")
	dash_duo.start_server(app)
	dash_duo.wait_for_text_to_equal("#corpus-select-title", "Use an existing corpus", timeout=4)
	
	delete_btn = dash_duo.driver.find_element_by_id("delete-btn")
	dash_duo.multiple_click(delete_btn, 1)

	corpus = dash_duo.driver.find_element_by_id('delete-corpus-select-dropdown')
	dash_duo.multiple_click(corpus, 1)
	opt = dash_duo.find_element('#delete-corpus-select-dropdown > div > div:nth-child(2) > div > div > div > div > div:nth-child(2)')
	dash_duo.multiple_click(opt, 1)
	delete_btn = dash_duo.find_element("#confirm-delete > button")
	dash_duo.multiple_click(delete_btn, 1)
Ejemplo n.º 16
0
def test_001_unemployed_officer(dash_duo):
    app = import_app("app")
    dash_duo.start_server(app)
    # close out of modal disclaimer
    dash_duo.multiple_click("#disclaimer_btn", 1)
    dash_duo.multiple_click("#close", 1)
    time.sleep(0.5)
    inputbox = dash_duo.find_element("#officer_input")
    dash_duo.find_element("#data_html")
    inputbox.send_keys("Feaman, Adam\n")
    dash_duo.multiple_click("#submit", 1)
    dash_duo.wait_for_contains_text("#officer_name", "Feaman")
    dash_duo.wait_for_contains_text("#officer-info",
                                    "No longer employed with the SLMPD")
Ejemplo n.º 17
0
def test_render_component(dash_duo):
    # Start a dash app contained as the variable `app` in `usage.py`
    app = import_app('usage')
    dash_duo.start_server(app)

    # Check that the genome loaded
    dash_duo.wait_for_text_to_equal('#igv-current_genome', 'ASM985889v3')

    # Check that both tracks leaded
    tracks = dash_duo.find_elements('.igv-track-label')

    assert tracks[0].text == 'Annotations'
    assert tracks[1].text == 'Genes'
    
Ejemplo n.º 18
0
def test_rere002_area_dropdown_changes_stats(dash_duo):
    """
    GIVEN the dash app page is loaded
    WHEN the area dropdown is changed to Hackney
    THEN the card title for the stats panel is also changed to Hackney.

    Note: using select_dcc_dropdown(elem_or_selector, value=None, index=None) didn't implement the selected value
    """
    app = import_app(app_file='apps.recycle_app.recycle_app')
    dash_duo.start_server(app)
    dash_duo.wait_for_element("#area-select", timeout=4)
    select_input = dash_duo.find_element("#area-select input")
    select_input.send_keys("Hackney")
    select_input.send_keys(Keys.RETURN)
    dash_duo.driver.implicitly_wait(5)
    assert 'HACKNEY' in dash_duo.find_element("#card-name").text, "'HACKNEY' should appear in the card name"
Ejemplo n.º 19
0
def test_one(dash_duo):
    app = import_app("tests.app")
    dash_duo.start_server(app)
    dash_duo.wait_for_text_to_equal(
        "h2", "Needleman-Wunsch, Smith-Waterman and Entrez", timeout=4)
    #assert dash_duo.find_element("h3").text == "Objective"
    assert dash_duo.find_element("h3").text == "PAM BLOSUM + NCBI"
    assert dash_duo.get_logs(
    ) == [], "Browser console should contain no errors"
    '''
    dash_duo.wait_for_element("#parameters-link", timeout=4)
    dash_duo.multiple_click("#parameters-link", clicks=1)
    dash_duo.wait_for_text_to_equal("1.  To access a sequence from NCBI using accession number, enter it here")
    assert dash_duo.find_element("#btn-email").text == "Store Email"
    #print('done')
    '''
    return None
Ejemplo n.º 20
0
def test_render_component(dash_duo):
    app = import_app('usage')
    dash_duo.start_server(app)

    # select the main wordcloud component
    my_component = dash_duo.wait_for_element_by_css_selector('#wordcloud')

    # select one of the options for controlling the input, the last one from the list
    # so we know it will be disabled in the begging
    input_selection = dash_duo.wait_for_element_by_css_selector(
        '#choice > label:last-child')

    # we click it
    input_selection.click()

    # than let's wait again for the svg to render again
    dash_duo.wait_for_element_by_css_selector('#wordcloud > svg > g > text')
Ejemplo n.º 21
0
def test_bbaaa001(dash_duo):
    """
    Dash documentation on this is here https://dash.plotly.com/testing, it's not very thorough.
    To install chromedriver, you download it from the website then copy it to PATH - on mac this meant moving it to
    /usr/local/bin. At time of writing it couldn't be version 85.
    To run this hit the below while in the project root directory.
    python -m pytest dash_test/
    """

    app = import_app("dash_test.app")
    dash_duo.start_server(app)

    dash_duo.wait_for_text_to_equal("h1", "About", timeout=10)

    assert dash_duo.find_element("em").text == "Sources"

    assert dash_duo.get_logs() == [], "Browser console should contain no error"

    return None
def test_render_component(dash_duo):
    # Start a dash app contained as the variable `app` in `usage.py`
    app = import_app('usage')
    dash_duo.start_server(app)

    # Get the generated component input with selenium
    # The html input will be a children of the #input dash component
    my_component = dash_duo.find_element('#input > input')

    assert 'my-value' == my_component.get_attribute('value')

    # Clear the input
    dash_duo.clear_input(my_component)

    # Send keys to the custom input.
    my_component.send_keys('Hello dash')

    # Wait for the text to equal, if after the timeout (default 10 seconds)
    # the text is not equal it will fail the test.
    dash_duo.wait_for_text_to_equal('#output', 'You have entered Hello dash')
Ejemplo n.º 23
0
def test_callbacks(dash_duo):
    expected = {
        'columns': "['Day of Week']",
        'rows': "['Party Size']",
        'row_order': 'key_a_to_z',
        'col_order': 'key_a_to_z',
        'aggregator': 'Average',
        'renderer': 'Grouped Column Chart',
    }

    app = import_app('usage')
    dash_duo.start_server(app)

    for prop in expected:
        try:
            dash_duo.wait_for_text_to_equal(
                f'#{prop}', expected[prop], timeout=4
            )
        except TimeoutException:
            raise Exception(f"Attribute '{prop}' failed to render correctly.")
def test_upload(dash_duo):
	app = import_app("app")
	dash_duo.start_server(app)
	dash_duo.wait_for_text_to_equal("#corpus-select-title", "Use an existing corpus", timeout=4)
	
	upload_btn = dash_duo.driver.find_element_by_id("upload-btn")
	dash_duo.multiple_click(upload_btn, 1)

	uploader = dash_duo.find_element("[name='upload-data-upload']")
	
	import os
	cwd = os.getcwd()
	uploader.send_keys(cwd+"/doc/sample_data.csv")
	
	time.sleep(2)

	#choose year column
	dropdown = dash_duo.find_element("#select-year-dropdown > div > div")
	dash_duo.multiple_click(dropdown, 1)
	
	opt = dash_duo.find_element('#select-year-dropdown > div > div:nth-child(2) > div > div > div > div > div:nth-child(2)')
	dash_duo.multiple_click(opt, 1)
	
	#choose content column
	dropdown = dash_duo.find_element("#select-content-dropdown > div > div")
	dash_duo.multiple_click(dropdown, 1)
	
	opt = dash_duo.find_element('#select-content-dropdown > div > div:nth-child(2) > div > div > div > div > div:nth-child(7)')
	dash_duo.multiple_click(opt, 1)

	corpus_name = dash_duo.driver.find_element_by_id("uploaded-corpus-name")
	corpus_name.send_keys('_test_upload')
	time.sleep(1)
	assert 'sample_data_test_upload' == corpus_name.get_attribute('value')

	submit_btn = dash_duo.driver.find_element_by_id("submit-corpus")
	dash_duo.multiple_click(submit_btn, 1)

	time.sleep(10)
def test_main(dash_duo):
	app = import_app("app")
	dash_duo.start_server(app)
	dash_duo.wait_for_text_to_equal("#corpus-select-title", "Use an existing corpus", timeout=4)
	
	#---test to choose the pre-installed sample data---
	# choose corpus "sample_data"
	corpus = dash_duo.driver.find_element_by_id('index-choose_corpus')
	dash_duo.multiple_click(corpus, 1)
	opt = dash_duo.driver.find_element_by_id('react-select-2--list')
	dash_duo.multiple_click(opt, 1)
	dash_duo.wait_for_text_to_equal("#react-select-2--value-item", "sample_data", timeout=3)

	# choose to create a new analysis
	saved_analysis = dash_duo.driver.find_element_by_id('index-choose-save')
	dash_duo.wait_for_text_to_equal("#react-select-3--value-item", "create new", timeout=3)

	#---start---
	start = dash_duo.driver.find_element_by_id("start-exp")
	dash_duo.multiple_click(start, 1)

	# leave some time to load
	time.sleep(2)

	#---test year range---
	year_from = dash_duo.find_element("#year-from > Div > span > input")
	year_to = dash_duo.find_element("#year-to > Div > span > input")
	# default values
	assert '2012' == year_from.get_attribute('value')
	assert '2018' == year_to.get_attribute('value')

	# test to change value
	dash_duo.clear_input(year_from)
	year_from.send_keys('2013')
	assert '2013' == year_from.get_attribute('value')

	
	#---test to type base term---
	base_term = dash_duo.driver.find_element_by_id("base-term")
	base_term.send_keys('marriage')
	time.sleep(1)
	assert 'marriage' == base_term.get_attribute('value')


	#---test "Add Related Words"---
	
	# The word2vec in the app should find a list of 
	# related words for the base term.
	# In our test example, it should be the word "sex".
	first_candidate = dash_duo.find_element("#candidates > div > div > label")
	assert "sex" == first_candidate.text
	dash_duo.multiple_click(first_candidate, 1)

	# add it to the query
	add_single = dash_duo.driver.find_element_by_id("add-single")
	dash_duo.multiple_click(add_single, 1)

	# delete it from the quey
	added = dash_duo.find_element("#added-terms-fromside > div > div > label")
	assert "sex" == added.text

	dash_duo.multiple_click(added, 1)

	# mannually add
	manu_add = dash_duo.driver.find_element_by_id("manu-add")
	manu_input = dash_duo.driver.find_element_by_id("manu-term")
	manu_input.send_keys('equality') # single term
	dash_duo.multiple_click(manu_add, 1)
	dash_duo.clear_input(manu_input)
	manu_input.send_keys('same sex') # phrase
	dash_duo.multiple_click(manu_add, 1)


	#---test "Sentence" tab---
	sent_tab = dash_duo.driver.find_element_by_id("Specs-tab")
	dash_duo.multiple_click(sent_tab, 1)
	time.sleep(1)

	# check the query for the ranking
	current_query = dash_duo.driver.find_element_by_id("current_query")
	assert "equality | same sex | marriage" == current_query.text

	# check the number of relevant sentences (i.e. the length of the ranking table)
	assert "107" == dash_duo.find_element("#rel_sent > div > div > div").text

	# open the pop up of the first result in the ranking table
	r1 = dash_duo.find_element("tr > td")
	dash_duo.multiple_click(r1, 1)

	# choose the term "couples", check term frequency, and add to the query
	term = dash_duo.find_element("#pop-up-sent div:nth-child(19) > div > label")
	dash_duo.multiple_click(term, 1)
	dash_duo.multiple_click(dash_duo.driver.find_element_by_id("check_sf"), 1)
	dash_duo.multiple_click(dash_duo.driver.find_element_by_id("add-to-query"), 1)

	# close the pop
	clost_btn = dash_duo.driver.find_element_by_id("markdown_close")
	dash_duo.multiple_click(clost_btn, 1)
	time.sleep(1)

	# current query should update
	current_query = dash_duo.driver.find_element_by_id("current_query")
	assert "equality | same sex | couples | marriage" == current_query.text

	# check the ranking has been updated
	assert "112" == dash_duo.find_element("#rel_sent > div > div > div").text


	#---test "Grouping" tab---
	group_tab = dash_duo.driver.find_element_by_id("Group-tab")
	dash_duo.multiple_click(group_tab, 1)
	time.sleep(1)

	# make a group
	group0_name = dash_duo.find_element("#make-groups > div > input")
	dash_duo.clear_input(group0_name)
	group0_name.send_keys('test group') # rename the group
	time.sleep(1)
	assert "test group" == dash_duo.find_element("#make-groups > div > input").get_attribute('value')

	# choose terms for the group
	# add "marriage"
	dropdown = dash_duo.find_element("#make-groups > div > div")
	dash_duo.multiple_click(dropdown, 1)
	t1 = dash_duo.find_element('#make-groups > div > div > div div:nth-child(1) > div > div > div > div:nth-child(1)')
	dash_duo.multiple_click(t1, 1)
	# add "equality"
	dash_duo.multiple_click(dropdown, 1)
	t2 = dash_duo.find_element('#make-groups > div > div > div div:nth-child(1) > div > div > div > div:nth-child(1)')
	dash_duo.multiple_click(t2, 1)

	# create a new group
	add_group_btn = dash_duo.driver.find_element_by_id("add_group")
	dash_duo.multiple_click(add_group_btn, 1)
	
	# add "same sex"
	dropdown = dash_duo.find_element("#make-groups > div:nth-child(2) > div")
	dash_duo.multiple_click(dropdown, 1)
	t3 = dash_duo.find_element('#make-groups > div:nth-child(2) > div > div div:nth-child(1) > div > div > div > div:nth-child(3)')
	dash_duo.multiple_click(t3, 1)


	# compound group
	comp_group_btn = dash_duo.driver.find_element_by_id("comp_group")
	dash_duo.multiple_click(comp_group_btn, 1)

	# include two groups into one
	dropdown = dash_duo.find_element("#make-groups > div:nth-child(3) > div")
	dash_duo.multiple_click(dropdown, 1)
	g1 = dash_duo.find_element('#make-groups > div:nth-child(3) > div > div div:nth-child(1) > div > div > div > div:nth-child(1)')
	dash_duo.multiple_click(g1, 1)
	dash_duo.multiple_click(dropdown, 1)
	g2 = dash_duo.find_element('#make-groups > div:nth-child(3) > div > div div:nth-child(1) > div > div > div > div:nth-child(1)')
	dash_duo.multiple_click(g2, 1)

	# test toggle of "ANY or ALL", set to "ANY"
	toggle = dash_duo.find_element("#make-groups > div:nth-child(3) div:nth-child(3) > div > div > div:nth-child(2)")
	dash_duo.multiple_click(toggle, 1)

	# delete group
	add_group_btn = dash_duo.driver.find_element_by_id("add_group") #add a new group
	dash_duo.multiple_click(add_group_btn, 1)
	delete_btn = dash_duo.find_element("#make-groups > div:nth-child(4) div:nth-child(4) > button")
	dash_duo.multiple_click(delete_btn, 1) #delete
	
	#---test "Graph" tab---
	graph_tab = dash_duo.driver.find_element_by_id("Graph-tab")
	dash_duo.multiple_click(graph_tab, 1)
	time.sleep(1)
	
	dropdown = dash_duo.find_element("#count_prop-dropdown > div > div")
	dash_duo.multiple_click(dropdown, 1)

	# choose to show the proportion
	prop_opt = dash_duo.find_element('#count_prop-dropdown > div > div:nth-child(2) > div > div > div > div > div:nth-child(3)')
	dash_duo.multiple_click(prop_opt, 1)
	time.sleep(2)
	

	#---test saving---
	save_btn = dash_duo.driver.find_element_by_id("save-analysis") #add a new group
	dash_duo.multiple_click(save_btn, 1)
	
	save_name = dash_duo.driver.find_element_by_id("save-name")
	save_name.send_keys('test save')
	time.sleep(1)
	assert 'test save' == save_name.get_attribute('value')

	save_btn = dash_duo.driver.find_element_by_id("save-add")
	dash_duo.multiple_click(save_btn, 1)
Ejemplo n.º 26
0
def test_install(cookies, dash_duo):
    results = cookies.bake(extra_context={
        'project_name': 'Test Component',
        'author_name': 'test',
        'author_email': 'test',
        'r_prefix': 'dash',
    })

    # Add the generated project to the path so it can be loaded from usage.py
    # It lies somewhere in a temp directory created by pytest-cookies
    sys.path.insert(0, str(results.project))

    # Test that `usage.py` works after building the default component.
    app = import_app('usage')
    dash_duo.start_server(app)

    my_component = dash_duo.find_element('#input > input')
    assert 'my-value' == my_component.get_attribute('value')

    dash_duo.clear_input(my_component)
    my_component.send_keys('Hello dash')
    dash_duo.wait_for_text_to_equal('#output', 'You have entered Hello dash')

    # Check for the existence of the right autogenerated files (R etc)
    # We'll leave their contents to other tests at least for now,
    # but existence tests verify that we can make the right directories
    # on a clean installation.

    expected_files = [
        # base cookiecutter
        ['README.md'],
        ['package.json'],
        ['LICENSE'],
        # Py
        ['test_component', '__init__.py'],
        ['test_component', '_imports_.py'],
        ['test_component', 'TestComponent.py'],
        ['test_component', 'test_component.min.js'],
        ['test_component', 'test_component.min.js.map'],
        ['test_component', 'package-info.json'],
        ['test_component', 'metadata.json'],
        # R
        ['DESCRIPTION'],
        ['NAMESPACE'],
        ['R', 'dashTestComponent.R'],
        ['R', 'internal.R'],
        ['man', 'dashTestComponent.Rd'],
        ['inst', 'deps', 'test_component.min.js'],
        ['inst', 'deps', 'test_component.min.js.map'],
    ]

    for path in expected_files:
        path_str = str(results.project.join(*path))
        assert os.path.exists(path_str), path_str

    node_modules = str(results.project.join('node_modules'))

    if sys.platform == 'win32':
        # Fix delete long names on Windows.
        # pytest-cookies have trouble deleting some file generated by webpack.
        node_modules = '\\\\?\\' + node_modules

    shutil.rmtree(node_modules)
Ejemplo n.º 27
0
def test_percy(dash_duo):
    app = import_app('usage')
    dash_duo.start_server(app)
    dash_duo.wait_for_element('#columns')
    dash_duo.percy_snapshot("usage.py")
Ejemplo n.º 28
0
def run_recycle_app(dash_duo):
    app = import_app("apps.recycle_app.app")
    yield dash_duo.start_server(app)
Ejemplo n.º 29
0
def run_paralympics_app(dash_duo):
    app = import_app("apps.paralympic_app.paralympic_app")
    yield dash_duo.start_server(app)