def test_ok_offset(self): query = { 'limit': '10', 'offset': '10', } sql = db.make_sql(query) assert sql == 'SELECT id, title, url, created FROM news LIMIT 10 OFFSET 10'
def test_ok_order_limit(self): query = { 'order': 'title DESC', 'limit': '10', } sql = db.make_sql(query) assert sql == 'SELECT id, title, url, created FROM news ORDER BY title DESC LIMIT 10'
def test_fail_order_direction(self): query = {'order': 'title some'} with pytest.raises(RuntimeError) as exinfo: db.make_sql(query) assert 'incorrect order direction' in str(exinfo.value)
def test_fail_order(self): query = {'order': 'hah'} with pytest.raises(RuntimeError) as exinfo: db.make_sql(query) assert 'incorrect order' in str(exinfo.value)
def test_ok_limit(self): query = {'limit': '10'} sql = db.make_sql(query) assert sql == 'SELECT id, title, url, created FROM news LIMIT 10'
def test_ok_order_asc(self): query = {'order': 'url asc'} sql = db.make_sql(query) assert sql == 'SELECT id, title, url, created FROM news ORDER BY url ASC LIMIT 5'
def test_ok_order(self): query = {'order': 'title'} sql = db.make_sql(query) assert sql == 'SELECT id, title, url, created FROM news ORDER BY title LIMIT 5'
def test_ok_no_args(self): query = {} sql = db.make_sql(query) assert sql == 'SELECT id, title, url, created FROM news LIMIT 5'
def test_fail_limit(self): query = {'limit': '-10'} with pytest.raises(RuntimeError) as exinfo: db.make_sql(query) assert 'incorrect limit' in str(exinfo.value)