(bukudb, app, client, mode, favicons, new_tab, url, netloc, title)
| 326 | _test_env_entry_render_params(bukudb, app, client, mode, True, True, url, netloc, title) |
| 327 | |
| 328 | def _test_env_entry_render_params(bukudb, app, client, mode, favicons, new_tab, url, netloc, title): |
| 329 | desc, tags = 'Foo bar baz', ',bar,baz,foo,' |
| 330 | _add_rec(bukudb, url, title, tags, desc) |
| 331 | _tags = tags.strip(',').split(',') |
| 332 | if mode: |
| 333 | app.config.update({'BUKUSERVER_URL_RENDER_MODE': mode}) |
| 334 | if favicons is not None: |
| 335 | app.config.update({'BUKUSERVER_DISABLE_FAVICON': not favicons}) |
| 336 | if new_tab is not None: |
| 337 | app.config.update({'BUKUSERVER_OPEN_IN_NEW_TAB': new_tab}) |
| 338 | |
| 339 | dom = assert_response(client.get('/bookmark/'), '/bookmark/') |
| 340 | cell = ' '.join(etree.tostring(dom.xpath(f'//td{xpath_cls("col-entry")}')[0], encoding='unicode').strip().split()) |
| 341 | target = '' if not new_tab else ' target="_blank"' |
| 342 | icon = '' if not favicons else (netloc and f'<img class="favicon" src="http://www.google.com/s2/favicons?domain={netloc}"/> ') |
| 343 | urltext = title or '<EMPTY TITLE>' |
| 344 | _title = (urltext if not netloc and mode in ('full', None) else f'<a href="{url}"{target}>{urltext}</a>') |
| 345 | prefix = f'<td class="col-entry"> {icon}<span class="title" title="{url}">{_title}</span>' |
| 346 | tags = [f'<a class="btn badge badge-secondary" href="/bookmark/?flt0_tags_contain={s}">{s}</a>' for s in _tags] |
| 347 | netloc_tag = ('' if mode == 'netloc' or not netloc else |
| 348 | f'<a class="btn badge badge-success" href="/bookmark/?flt0_url_netloc_match={netloc}">netloc:{netloc}</a>') |
| 349 | suffix = f'<div class="tag-list">{netloc_tag}{"".join(tags)}</div><div class="description">{desc}</div> </td>' |
| 350 | if mode == 'netloc': |
| 351 | _netloc = netloc and f'<span class="netloc"> (<a href="/bookmark/?flt0_url_netloc_match={netloc}">{netloc}</a>)</span>' |
| 352 | assert cell == prefix + _netloc + suffix |
| 353 | elif mode == 'netloc-tag': |
| 354 | assert cell == prefix + suffix |
| 355 | else: |
| 356 | assert cell == f'{prefix}<span class="link"><a href="{url}"{target}>{url}</a></span>{suffix}' |
| 357 | |
| 358 | |
| 359 | readonly = env_fixture('BUKUSERVER_READONLY', params=[False, True, None]) |
no test coverage detected