Skip to content

lime_app

Scope: function | Returns: LimeApplication

The lime_app fixture provides a LimeApplication instance connected to the test database, running as an admin user. It is the primary entry point for tests that need to interact with the application layer.

Basic usage

def test_company_can_be_created(lime_app, save_lime_objects):
    company = lime_app.limetypes.company(name="Acme")

    saved = save_lime_objects(company)

    assert saved.id is not None

Extending the fixture

Override lime_app in your conftest.py to run additional setup after the application is ready. pytest resolves the lime_app parameter to the definition from lime_test, so the override can build on top of it:

@pytest.fixture
def lime_app(lime_app, save_lime_objects):
    coworker = lime_app.limetypes.coworker(firstname="Admin", lastname="User")
    save_lime_objects(coworker, application=lime_app)
    return lime_app

Configurable dependencies

The composition of the produced LimeApplication can be adjusted by overriding three fixtures in your conftest.py:

Fixture Controls Default
lime_app_acl Access control layer AlwaysAllowAcl — all operations permitted
admin_user The user the application runs as User with username admin fetched from the database
lime_db_app_config Application configuration Empty AppConfig

Override any of these in your conftest.py to change how lime_app is constructed for your tests.

Info

lime_app ensures its user is an administrator — a custom admin_user is automatically added to the Administrators group if it is not already a member.