RequiresTm1Engine
from skipcheck_tm1_testcontainers import RequiresTm1Engine Runs a test class or method against a real TM1 v12 engine, and skips it when there
isn't one. For TM1 11, use RequiresTm1.
Tests are skipped, not failed, when Docker isn't available or no
Tm1EngineSource is configured, so a build without IBM software stays green. A
source that is configured but wrong fails instead.
One engine serves the whole test JVM (Tm1EngineContainer.shared), and each
test class gets a database of its own, created when the class first asks for it and
dropped when the class is done. So classes don't see each other's objects. Declare a
Tm1Database parameter on a test method, constructor or lifecycle method to get
it; a Tm1EngineContainer parameter gets the engine.
# Every test in the module needs TM1 v12, and is skipped without one
pytestmark = pytest.mark.requires_tm1_engine
# A database of this module's own, dropped when the module is done
def test_lists_cubes(tm1_database: Tm1Database) -> None:
db = tm1_database
response = httpx2.get(db.rest_url + "Cubes?$select=Name", headers=db.login().authorize({}))
assert response.status_code == 200
A database takes about 13 seconds to create and 5 to drop. share_database gives
a class the engine's one shared database instead, at no cost: its tests then need
uniquely named objects, and to delete them afterwards:
# The engine's one shared database instead: nothing to create, but give what you make a unique name
@pytest.mark.requires_tm1_engine(share_database=True)
def test_reads_the_servers_name(tm1_database: Tm1Database) -> None:
db = tm1_database
response = httpx2.get(db.rest_url + "Configuration/ServerName/$value", headers=db.login().authorize({}))
assert response.status_code == 200
"A test class" is the unit each language's test framework shares set-up over: a JUnit class here (with its nested classes), a module in pytest, a class in xUnit, and a file in vitest.
Members
NO_SOURCE_MESSAGE static | Why tests skip when no source is configured, and what to set. |
mark property | |
share_database property | Whether the class uses the engine's shared database, tm1, rather than one of its own. |
min_version property | The oldest TM1 the tests apply to, such as 12.6; they're skipped on an older engine. |
NO_SOURCE_MESSAGE
staticNO_SOURCE_MESSAGEWhy tests skip when no source is configured, and what to set.
mark
propertymarkmin_version
propertymin_version The oldest TM1 the tests apply to, such as 12.6; they're skipped on an
older engine. Checking it starts the engine.