update test/README.md to be more aligned with the current state

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-12-01 12:27:14 -08:00
parent c09784d58f
commit 0435c56a41
No known key found for this signature in database
GPG key ID: F7E46DED420788F3

View file

@ -117,13 +117,12 @@ To run `sharness` shell test suites (requires Arch Linux):
To run `pytest` Python test suites: To run `pytest` Python test suites:
$ make -C test pytest $ pytest
**Note:** For SQLite tests, users may want to use `eatmydata` **Note:** For SQLite tests, users may want to use `eatmydata`
to improve speed: to improve speed:
$ eatmydata -- make -C test sh $ eatmydata -- make -C test sh
$ eatmydata -- make -C test pytest
To produce coverage reports related to Python when running tests manually, To produce coverage reports related to Python when running tests manually,
use the following method: use the following method:
@ -147,11 +146,9 @@ Almost all of our `pytest` suites use the database in some way. There
are a few particular testing utilities in `aurweb` that one should are a few particular testing utilities in `aurweb` that one should
keep aware of to aid testing code: keep aware of to aid testing code:
- `aurweb.testing.setup_init_db(*tables)` - `db_test` pytest fixture
- Prepares test database tables to be cleared before a test - Prepares test databases for the module and cleans out database
is run. Be careful not to specify any tables we depend on tables for each test function requiring this fixture.
for constant records, like `AccountTypes`, `DependencyTypes`,
`RelationTypes` and `RequestTypes`.
- `aurweb.testing.requests.Request` - `aurweb.testing.requests.Request`
- A fake stripped down version of `fastapi.Request` that can - A fake stripped down version of `fastapi.Request` that can
be passed to any functions in our codebase which use be passed to any functions in our codebase which use
@ -168,14 +165,16 @@ Example code:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup(): def setup(db_test):
setup_test_db(User.__tablename__) return
@pytest.fixture @pytest.fixture
def user(): def user():
yield db.create(User, Passwd="testPassword", ...) with db.begin():
user = db.create(User, Passwd="testPassword", ...)
yield user
def test_user_login(user): def test_user_login(user: User):
assert isinstance(user, User) is True assert isinstance(user, User) is True
fake_request = Request() fake_request = Request()