new: test: test_get_max_id
This commit is contained in:
parent
bb2e49566a
commit
d66d2e3570
2
buku
2
buku
@ -518,7 +518,7 @@ class BukuDb:
|
||||
resultset = self.cur.fetchall()
|
||||
return resultset[0][0] if resultset else -1
|
||||
|
||||
def get_max_id(self):
|
||||
def get_max_id(self) -> int:
|
||||
"""Fetch the ID of the last record.
|
||||
|
||||
Returns
|
||||
|
@ -1435,6 +1435,21 @@ def test_exportdb_single_rec(tmpdir):
|
||||
assert f.read()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'urls, exp_res',
|
||||
[
|
||||
[[], -1],
|
||||
[['http://example.com'], 1],
|
||||
[['htttp://example.com', 'http://google.com'], 2],
|
||||
])
|
||||
def test_get_max_id(urls, exp_res):
|
||||
with NamedTemporaryFile(delete=False) as f:
|
||||
db = BukuDb(dbfile=f.name)
|
||||
if urls:
|
||||
list(map(lambda x: db.add_rec(x), urls))
|
||||
assert db.get_max_id() == exp_res
|
||||
|
||||
|
||||
# Helper functions for testcases
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user