Example #1
0
def test_components(chrome_driver, build_path):
    """Tests plotly."""

    app = App(rows=len(visuals), directory=build_path)
    for controller in controllers:
        app.add_sidebar(controller)

    for vis in visuals:
        app.add(vis)
    app.build()

    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(),
                                       os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(build_path, 'src/server.py'),
                              env=env)

    time.sleep(5)

    chrome_driver.get('http://localhost:9991')
    chrome_driver.implicitly_wait(5)

    logs = chrome_driver.get_log('browser')
    for log in logs:
        if log['level'] == 'SEVERE':
            raise Exception(log['message'])

    server.kill()
Example #2
0
def construct():
    from bowtie import App
    app = App(debug=True)
    app.add_sidebar(sigma)
    app.add(mainplot)
    app.schedule(0.1, walk)

    app.build()
Example #3
0
def test_build(build_path):
    """Tests the build process."""
    reset_uuid()
    ctrl = Nouislider()
    viz = Plotly()

    app = App(directory=build_path)
    app.add_sidebar(ctrl)
    app.add(viz)
    app.subscribe(callback, ctrl.on_change)
    app.build()
Example #4
0
def test_markdown(chrome_driver, build_path):
    """Test markdown and text widgets."""
    app = App(directory=build_path)
    app.add(mark)
    app.add_sidebar(side)
    app.add_sidebar(text)
    app.subscribe(write, text.on_change)
    app.build()

    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(),
                                       os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(build_path, 'src/server.py'),
                              env=env)

    time.sleep(5)

    chrome_driver.get('http://*****:*****@style='grid-area: 1 / 2 / 2 / 3; position: relative;']")

    assert 'top' in output.text
    assert 'middle' in output.text
    assert 'link' in output.text

    txtctrl.send_keys('apple')
    time.sleep(1)

    assert 'apple' in output.text

    txtctrl.send_keys('banana')
    time.sleep(1)

    assert 'apple' in output.text
    assert 'banana' in output.text

    server.kill()
Example #5
0
def test_plotly(chrome_driver, build_path):
    """Tests plotly."""

    app = App(directory=build_path)
    app.add(viz)
    app.add_sidebar(ctrl)
    app.add_sidebar(ctrl2)
    app.subscribe(callback, ctrl.on_change)
    app.subscribe(callback, ctrl2.on_click)
    app.build()

    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(),
                                       os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(build_path, 'src/server.py'),
                              env=env)

    time.sleep(5)

    chrome_driver.get('http://localhost:9991')
    chrome_driver.implicitly_wait(5)

    assert chrome_driver.title == 'Bowtie App'

    button = chrome_driver.find_element_by_class_name('ant-btn')
    button.click()

    points = chrome_driver.find_elements_by_class_name('point')

    logs = chrome_driver.get_log('browser')
    for log in logs:
        if log['level'] == 'SEVERE':
            raise Exception(log['message'])

    assert len(points) == 4

    server.kill()