예제 #1
0
def test_plotly(remove_build):
    """Tests plotly."""
    viz = Plotly()
    ctrl = Nouislider()
    ctrl2 = Button()

    path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'build')
    layout = Layout(directory=path)
    layout.add(viz)
    layout.add_sidebar(ctrl)
    layout.add_sidebar(ctrl2)
    layout.subscribe(callback, ctrl.on_change)
    layout.subscribe(callback, ctrl2.on_click)
    layout.build()

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

    driver = PhantomJS()
    driver.get('http://localhost:9991')

    assert driver.title == 'Bowtie App'

    server.kill()
예제 #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from queue import Queue

import pendulum

from bowtie.control import Textbox, Button

LINES = Queue(maxsize=50)

talk = Textbox()
click = Button('submit')
chat = Textbox(autosize=True, disabled=True, area=True)

def to_text(entry):
    return f'{entry[0].diff_for_humans()}: {entry[1]}'

def update_chat():
    chat.do_text('\n'.join(map(to_text, list(LINES.queue)[::-1])))

def clicked():
    text = talk.get()
    entered(text)

def entered(text):
    if LINES.full():
        _ = LINES.get()
    tt = text[:144]
    now = pendulum.utcnow()
    LINES.put((now, tt))
예제 #3
0
# -*- coding: utf-8 -*-
"""Test markdown and text widgets."""

import time

import pytest
from bowtie import App, cache
from bowtie.control import Button
from bowtie.tests.utils import reset_uuid, server_check

reset_uuid()

# pylint: disable=invalid-name
button = Button()
store = {}


def click():
    """Update markdown text."""
    cache['a'] = 3
    assert cache[b'a'] == 3
    assert cache[u'a'] == 3
    cache[b'b'] = True
    assert cache[b'b']
    assert cache[u'b']


def test_keys():
    """Test invalid keys."""
    with pytest.raises(KeyError):
        cache[0] = 0
예제 #4
0
import pytest
from plotly.graph_objs import Scatter
from plotly.graph_objs import Layout as PlotLayout

from bowtie import App
from bowtie.control import Nouislider, Button
from bowtie.visual import Plotly
from bowtie.tests.utils import reset_uuid

reset_uuid()

# pylint: disable=invalid-name
viz = Plotly()
ctrl = Nouislider()
ctrl2 = Button()


def callback(*args):
    """dummy function"""
    # pylint: disable=unused-argument
    chart = {
        "data": [Scatter(x=[1, 2, 3, 4], y=[4, 1, 3, 7])],
        "app": PlotLayout(title="hello world")
    }
    viz.do_all(chart)


# pylint: disable=unused-argument
@pytest.fixture
def plotly(build_path, monkeypatch):
예제 #5
0
from bowtie.visual import Plotly, Markdown
from bowtie.control import Nouislider, Upload, Dropdown, Slider, Button, Textbox
from Analyzer.ResultAnalizer import ResultAnalyzer
from main import run_experiment
from utils.utils import *

sine_plot = Plotly()
freq_slider = Nouislider(caption='Aggregation time, ms',
                         minimum=50,
                         maximum=2000,
                         start=500)
upload = Upload(multiple=False, caption='Upload json config')
run_button = Button(label="Run the experiment!")
dropdown_src = Dropdown(caption='src_ips', labels=[''], values=[''])
dropdown_dst = Dropdown(caption='dst_ips', labels=[''], values=[''])
scale_factor_input = Nouislider(caption='Scaling factor',
                                start=1,
                                minimum=0,
                                maximum=1)
mark = Markdown(u'NNN')

#text = Textbox(area=True, autosize=True, placeholder='Enter markdown')

result_analyzer = ResultAnalyzer()
src_ips = []
dst_ips = []
initialized = False
config = None
config_valid = False

예제 #6
0
def test_subscribe_error():
    """Subscribe with incorrect argument order."""
    app = App()
    button = Button()
    with pytest.raises(TypeError):
        app.subscribe(3, button.on_click)
예제 #7
0
def buttons():
    """Four buttons."""
    return [Button() for _ in range(4)]