def test_client_add_dataset(): client.requests = test_add # OMG more monkey patching ec = Client('localhost:6363') ec.add('iris', example('iris.csv')) assert 'iris' in ec.dshape.measure.dict iris_data = bz_data(example('iris.csv')) assert ec.dshape.measure.dict['iris'] == iris_data.dshape
def test_client_add_dataset_with_args(): client.requests = test_add # OMG more monkey patching ec = Client('localhost:6363') ec.add('teams', 'sqlite:///' + example('teams.db'), 'teams', primary_key='teamID') assert 'teams' in ec.dshape.measure.dict teams_data = bz_data('sqlite:///' + example('teams.db') + '::teams') assert ec.dshape.measure.dict['teams'] == teams_data.dshape
def test_column(sql): t = bz_data(sql) r = list(t['x']) assert r == [1, 10, 100] assert list(t[['x']]) == [(1,), (10,), (100,)] assert int(t.count()) == 3
def sql(): data = [(1, 2), (10, 20), (100, 200)] sql = bz_data( 'sqlite:///:memory:::foo', dshape='var * {x: int, y: int}', ) into(sql, data) return sql
def test_expr_client_interactive(): c = Client('localhost:6363') t = bz_data(c) assert compute(t.accounts.name) == ['Alice', 'Bob'] assert (into(set, compute(by(t.accounts.name, min=t.accounts.amount.min(), max=t.accounts.amount.max()))) == set([('Alice', 100, 100), ('Bob', 200, 200)]))
def test_column(sql): t = bz_data(sql) r = list(t['x']) assert r == [1, 10, 100] assert list(t[['x']]) == [(1, ), (10, ), (100, )] assert int(t.count()) == 3
def test_expr_client_interactive(): c = Client('localhost:6363') t = bz_data(c) assert compute(t.accounts.name) == ['Alice', 'Bob'] assert (into( set, compute( by(t.accounts.name, min=t.accounts.amount.min(), max=t.accounts.amount.max()))) == set([('Alice', 100, 100), ('Bob', 200, 200)]))
def test_bz_data_all_in_one(): ec = bz_data('blaze://localhost:6363') assert str(discover(ec)) == str(discover(tdata))
def test_bz_data_non_default_port(): ec = bz_data('blaze://localhost:6364') assert ec.data.url == 'http://localhost:6364'
def test_bz_data_default_port(): ec = bz_data('blaze://localhost') assert str(discover(ec)) == str(discover(tdata))
def test_bz_data(): c = bz_data('blaze://localhost:6363') assert isinstance(c.data, Client) assert str(discover(c)) == str(discover(tdata))
def test_compute_client_with_multiple_datasets(): c = bz_data('blaze://localhost:6363') s = symbol('s', discover(c)) assert compute(s.accounts.amount.sum() + s.accounts2.amount.sum(), {s: c}) == 600
def test_client_dataset(): d = bz_data('blaze://localhost') assert list(map(tuple, into(list, d.accounts))) == into(list, df)
def test_client_dataset_fails(): with pytest.raises(ValueError): bz_data('blaze://localhost::accounts') with pytest.raises(ValueError): bz_data('blaze://localhost::accounts')
def sql(): data = [(1, 2), (10, 20), (100, 200)] sql = bz_data("sqlite:///:memory:::foo", dshape="var * {x: int, y: int}") into(sql, data) return sql