from argparse import Namespace from flask import current_app import pytest from buku import BukuDb from bukuserver import server from bukuserver.views import BookmarkModelView @pytest.fixture def client(tmp_path): test_db = tmp_path / 'test.db' app = server.create_app(test_db.as_posix()) app_context = app.test_request_context() app_context.push() client = app.test_client() return client @pytest.mark.parametrize('disable_favicon', [False, True]) def test_bookmark_model_view(tmp_path, client, disable_favicon): test_db = tmp_path / 'test.db' bukudb = BukuDb(dbfile=test_db.as_posix()) inst = BookmarkModelView(bukudb) model = Namespace( description='randomdesc', id=1, tags='tags1', title='Example Domain', url='http://example.com') # __import__('pdb').set_trace() current_app.config['BUKUSERVER_DISABLE_FAVICON'] = disable_favicon img_html = '' if not disable_favicon: img_html = \ ' ' res = inst._list_entry(None, model, 'Entry') exp_res = \ ( 'Example Domain
' 'http://example.com
' 'netloc:example.com' 'tags1' '
randomdesc') exp_res = ''.join([img_html, exp_res]) assert str(res) == exp_res