my eye

test_app.py

Raw

import pathlib

import sqlyte
import web

from indieweb_rocks.__web__ import app

db_path = pathlib.Path("site.db")
db_path_shm = pathlib.Path("site.db-shm")
db_path_wal = pathlib.Path("site.db-wal")


def unlink():
    db_path.unlink()
    db_path_shm.unlink()
    db_path_wal.unlink()


def test_index():
    # web.tx.host.db = sqlyte.db(db_path)

    with pathlib.Path("webcfg.ini").open("w") as fp:
        fp.write('SECRET = "test"')
    response = app.get("?secret=test")
    print(response.body)
    # assert response.status == "200 OK"

    def get_headings(h):
        return [_.text for _ in response.dom.select(f"h{h}")]

    # assert get_headings(2) == ["Database", "Migration"]
    # unlink()