new: dev: test api on empty database
This commit is contained in:
parent
a04dce8341
commit
695c45158a
@ -18,10 +18,28 @@ def test_cli(args, word):
|
||||
assert word in result.output
|
||||
|
||||
|
||||
def test_home(tmp_path):
|
||||
@pytest.fixture
|
||||
def client(tmp_path):
|
||||
test_db = tmp_path / 'test.db'
|
||||
app = server.create_app(test_db.as_posix())
|
||||
client = app.test_client()
|
||||
return client
|
||||
|
||||
|
||||
def test_home(client):
|
||||
rd = client.get('/')
|
||||
assert rd.status_code == 200
|
||||
assert not flask.g.bukudb.get_rec_all()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'url, exp_res', [
|
||||
['/api/tags', {'tags': []}],
|
||||
['/api/bookmarks', {'bookmarks': []}],
|
||||
['/api/bookmarks/search', {'bookmarks': []}]
|
||||
]
|
||||
)
|
||||
def test_api_empty_db(client, url, exp_res):
|
||||
rd = client.get(url)
|
||||
assert rd.status_code == 200
|
||||
assert rd.get_json() == exp_res
|
||||
|
Loading…
Reference in New Issue
Block a user