示例#1
0
def test_select_unique():
    """Test that it is possible to select a single row as a dict"""
    eq_(
        select_with_params(id='1', name='foo').unique, {
            'id': 1,
            'name': 'foo',
        })
示例#2
0
def test_select_with_keyword_params():
    """Test that parameters can be passed to a select."""
    eq_(
        select_with_params(id=1, name='foo').rows, [
            {
                'id': 1,
                'name': 'foo'
            },
        ])
示例#3
0
def test_update():
    """We can update and receive a row count."""
    res = simple_update(old='foo', new='woo')
    eq_(
        select_with_params(id='1', name='woo').unique, {
            'id': 1,
            'name': 'woo',
        })
    eq_(res, 1)
    eq_(simple_update(old='foo', new='woo'), 0)
示例#4
0
def test_select_with_insufficient_positional_params():
    """Test that required parameters are validated."""
    select_with_params(1).rows
示例#5
0
def test_select_with_insufficient_keyword_params():
    """Test that required parameters are validated."""
    select_with_params(id='1').rows
示例#6
0
def test_select_with_keyword_and_positional_params():
    """Test that selects reject mixed positional and keyword parameters"""
    select_with_params(1, name='foo').rows
示例#7
0
def test_simple_insert():
    """Test that we can execute simple transactions."""
    id = simple_insert(name='asdf5').value
    eq_(id, 4)
    assert select_with_params(id=id, name='asdf5').unique
示例#8
0
def test_insert():
    """Test that we can execute transactions."""
    id = do_insert('asdf1')
    eq_(id, 4)
    assert select_with_params(id=id, name='asdf1').unique
示例#9
0
def test_select_unique_no_results():
    """Test that unique select raises an error if there are no results"""
    select_with_params(id='1', name='zap').unique
示例#10
0
def test_delete():
    """We can delete and receive a row count."""
    res = simple_delete(name='foo')
    eq_(select_with_params(id='1', name='foo').rows, [])
    eq_(res, 1)
    eq_(simple_delete(name='foo'), 0)