From 9807b2fc587635c39c284aeb1cdd3e103158ff38 Mon Sep 17 00:00:00 2001 From: Riccardo Murri Date: Mon, 26 Jun 2017 12:04:32 +0200 Subject: [PATCH] Add tests for the new `Engine.resources` property. --- gc3libs/tests/test_core.py | 17 ++++++++++++++++- gc3libs/tests/test_engine.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/gc3libs/tests/test_core.py b/gc3libs/tests/test_core.py index 8496e639..b72816c0 100644 --- a/gc3libs/tests/test_core.py +++ b/gc3libs/tests/test_core.py @@ -29,7 +29,22 @@ from gc3libs.core import Core, MatchMaker from gc3libs.quantity import GB, hours -from gc3libs.testing.helpers import temporary_config_file +from gc3libs.testing.helpers import temporary_config_file, temporary_core + + +def test_core_resources(): + """ + Check that configured resources can be accessed through the `Core` object. + """ + with temporary_core() as core: + resources = core.resources + assert len(resources) == 1 + assert 'test' in resources + test_rsc = resources['test'] + # these should match the resource definition in `gc3libs.testing.helpers.temporary_core` + assert test_rsc.max_cores_per_job == 1 + assert test_rsc.max_memory_per_core == 1*GB + assert test_rsc.max_walltime == 8*hours def test_core_disable_resource_on_auth_init_failure(): diff --git a/gc3libs/tests/test_engine.py b/gc3libs/tests/test_engine.py index 74df2598..4cacd244 100644 --- a/gc3libs/tests/test_engine.py +++ b/gc3libs/tests/test_engine.py @@ -37,6 +37,21 @@ from gc3libs.testing.helpers import SimpleParallelTaskCollection, SimpleSequentialTaskCollection, SuccessfulApp, temporary_config, temporary_config_file, temporary_core, temporary_directory, temporary_engine +def test_engine_resources(): + """ + Check that configured resources can be accessed through the `Engine` object. + """ + with temporary_engine() as engine: + resources = engine.resources + assert len(resources) == 1 + assert 'test' in resources + test_rsc = resources['test'] + # these should match the resource definition in `gc3libs.testing.helpers.temporary_core` + assert test_rsc.max_cores_per_job == 1 + assert test_rsc.max_memory_per_core == 1*GB + assert test_rsc.max_walltime == 8*hours + + def test_engine_progress(num_jobs=1, transition_graph=None, max_iter=100): with temporary_engine() as engine: