Skip to content

test_core

python.tests.core.test_core

Unit testing of ensembl.core.models module.

TestCoreModels

Tests the ~ensembl.core.models ORMs

Source code in src/python/tests/core/test_core.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@pytest.mark.parametrize("test_dbs", [[{"src": "core_db"}]], indirect=True)
class TestCoreModels:
    """Tests the `~ensembl.core.models` ORMs"""

    dbc: UnitTestDB = None

    @pytest.fixture(scope="class", autouse=True)
    def setup(self, test_dbs: dict[str, UnitTestDB]) -> None:
        """Loads the required fixtures and values as class attributes.

        Args:
            test_dbs: Generator of unit test databases (fixture).
        """
        type(self).dbc = test_dbs["core_db"].dbc

    def test_create_db(self) -> None:
        """Test the creation of a database with the core models schema."""
        self.dbc.create_all_tables(Base.metadata)
        assert set(self.dbc.tables.keys()) == set(Base.metadata.tables.keys())

dbc: UnitTestDB = None class-attribute instance-attribute

setup(test_dbs)

Loads the required fixtures and values as class attributes.

Parameters:

Name Type Description Default
test_dbs dict[str, UnitTestDB]

Generator of unit test databases (fixture).

required
Source code in src/python/tests/core/test_core.py
29
30
31
32
33
34
35
36
@pytest.fixture(scope="class", autouse=True)
def setup(self, test_dbs: dict[str, UnitTestDB]) -> None:
    """Loads the required fixtures and values as class attributes.

    Args:
        test_dbs: Generator of unit test databases (fixture).
    """
    type(self).dbc = test_dbs["core_db"].dbc

test_create_db()

Test the creation of a database with the core models schema.

Source code in src/python/tests/core/test_core.py
38
39
40
41
def test_create_db(self) -> None:
    """Test the creation of a database with the core models schema."""
    self.dbc.create_all_tables(Base.metadata)
    assert set(self.dbc.tables.keys()) == set(Base.metadata.tables.keys())