"""The Imports & exports page's arrangement.
Two sections of equal halves — Imports (broker file ·
dividend statement) and Exports (download · what's in each) — and moved the
Import templates section into a **Manage templates** dialog.
The dialog is not just tidying: the section it replaces could install and
remove a template but never hand one back, so a correction made here could not
leave the machine. Download is the verb that closes the loop the contribution
flow opens.
"""
from __future__ import annotations
import re
import pytest
from test_routes import make_login
HTML = {"accept": "text/html"}
GOOD = b"""
name: Example Registry
match:
any:
- Example Registry Services
fields:
payment_date:
after: ["payment date"]
type: date
net_amount:
after: ["net amount"]
type: money
"""
@pytest.fixture
def admin(client, session_factory, tmp_path, monkeypatch, app_module):
"""Signed in as an admin, with the drop-in directory pointed at tmp_path —
the real default is `/data/formats`, which a test must never write to."""
monkeypatch.setattr(app_module.settings.imports, "templates_dir", str(tmp_path))
make_login(client, session_factory)
return tmp_path
def _page(client, session_factory) -> str:
make_login(client, session_factory)
response = client.get("/imports-exports", headers=HTML)
assert response.status_code == 200
return response.text
def test_the_page_has_an_imports_and_an_exports_section(client, session_factory):
page = _page(client, session_factory)
assert '
Imports
' in page
assert '
Exports
' in page
def test_the_import_templates_section_is_gone_from_the_page(client, session_factory):
"""It became a button. Templates are something you manage occasionally,
not a third of a page you read every time you import a file."""
page = _page(client, session_factory)
body = page[:page.index("