示例#1
0
def check_read(manager):
    expected_dates = ['2012-12-03', '2012-12-02', '2012-12-01']

    for row in manager(sql.select(s.stock)):
        stock = manager.read(Stock(*row))
        assert_equal(stock.quotes.keys(), expected_dates)  # check the ordering
        assert_equal(len(stock.quotes), 3)
示例#2
0
def check_parallel_import(loadercls):
    loader = loadercls(client, "save")
    files = toolbox.splitter(csvfile_with_header(), 1)
    files2 = toolbox.splitter(csvfile_no_header(), 1)
    with core.ScratchDB("config://scratch/psycopg2_uri", _util.create) as db:
        runner = core.Runner(db.conn)
        runner.pmap(loader, files)
        runner.pmap(loader, files2)
        print(runner(sql.select(client)))
示例#3
0
def test_joiners():
    assert_equal(str(s.book | I | s.book_author | I | s.author),
                 '<JOIN book INNER book_author INNER author>')
    assert_equal(str(s.book | I | s.book_author | L | s.author),
                 '<JOIN book INNER book_author LEFT author>')
    assert_equal(
        str(sql.select(s.book).where("title LIKE :a", a='%a')
        | L | s.reading_history), '''<JOIN 
(SELECT code, title, score FROM book
 WHERE title LIKE '%a') AS book LEFT reading_history>''')
示例#4
0
def check(manager):
    codes = sorted(b.code.strip() for b in manager(sql.select(s.book)))
    assert_equal(['0001', '0002'], codes)