Skip to content

database

Scope: function | Returns: LimeDatabase

The database fixture provides the database the test runs against. Each test gets a fresh in-memory SQLite database, so tests cannot interfere with each other. Most other fixtures depend on it, directly or indirectly.

Info

Tables for your limetypes are created lazily, the first time each limetype is accessed — see create_limetype_tables.

Prepopulated data

The database comes seeded with:

  • Groups Administrators and Users. They can be accessed through the administrators_group and users_group fixtures.
  • User admin (password admin), member of Administrators. This is the user lime_app runs as.
  • Users standard (password standard) and standard_2 (password standard_2), members of Users. These are the users lime_app_non_admin and lime_app_other_non_admin run as.
  • en_us as the only active and system language.

Every new user and group created in the database gets an identifier greater than 1000, which reflects the behavior on production.

Basic usage

Most tests don't use database directly — they go through higher-level fixtures such as lime_app. Declare it when you need engine-level access:

def test_something(database):
    with database.engine.begin() as connection:
        ...

For a ready-made open connection, use the connection fixture instead.