コード例 #1
0
def test_install(cookies, dash_threaded, selenium):
    results = cookies.bake(
        extra_context={
            'project_name': 'Test Component',
            'author_name': 'test',
            'author_email': 'test',
        })

    # 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.
    dash_threaded(import_app('usage'))

    input_component = wait_for_element_by_css_selector(selenium,
                                                       '#input > input')
    input_component.clear()
    input_component.send_keys('Hello dash component')

    wait_for_text_to_equal(selenium, '#output',
                           'You have entered Hello dash component')

    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)
コード例 #2
0
def usage_app(dash_threaded):
    # Start a dash app contained in `usage.py`
    # dash_threaded is a fixture by pytest-dash
    # It will load a py file containing a Dash instance named `app`
    # and start it in a thread.
    app = import_app('usage')
    dash_threaded(app)
    return app
コード例 #3
0
def test_start(dash_threaded, selenium):
    """Launch the app.

    `dash_threaded` is a fixture by `pytest-dash`.
    It will load a .py file containing a Dash instance
    and start it in a thread.
    """

    app = import_app('index')
    assert 'gallery', 'bioinformatics' in str(app.layout)

    # Test that `index.py` (the main gallery) works
    dash_threaded(app)
コード例 #4
0
def test_render_component(dash_threaded, selenium):
    # Start a dash app contained in `usage.py`
    # dash_threaded is a fixture by pytest-dash
    # It will load a py file containing a Dash instance named `app`
    # and start it in a thread.
    app = import_app('usage')
    dash_threaded(app)

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

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

    # Clear the input
    my_component.clear()

    # 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.
    wait_for_text_to_equal(selenium, '#output', 'You have entered Hello dash')
コード例 #5
0
def access_demo_app(dash_threaded, selenium, app_name):
    """mimic a user click on the app link from the gallery"""
    dash_bio_index = import_app('index')
    dash_threaded(dash_bio_index)
    link = wait_for_element_by_id(selenium, 'app-link-id-{}'.format(app_name))
    link.click()