mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-23 18:21:42 +08:00
Refactor make_module for tests
The original motivation for this refactor is to reuse make_module and drop TestMMDResolver._make_mmd. Some tests require a modulemd created and some tests also require those modulemd to be stored into database as a module build. The problem is db_session has to be passed to make_module even if no need to store into database. Major changes in this patch: * Argument db_session is optional. * Arguments requires_list and build_requires_list are replaced by a single argument dependencies which is a list of group of requires and buildrequires * A new make_module_in_db is created for creating and storing the new modulemd into database conveniently. * Tests are updated with the new make_module and make_module_in_db. Signed-off-by: Chenxiong Qi <cqi@redhat.com>
This commit is contained in:
@@ -30,7 +30,7 @@ from module_build_service import models
|
||||
from conf.config import TestConfiguration
|
||||
|
||||
from six.moves import reload_module
|
||||
from tests import app, init_data, make_module
|
||||
from tests import app, init_data, make_module_in_db
|
||||
|
||||
num_of_metrics = 18
|
||||
|
||||
@@ -71,7 +71,12 @@ def test_standalone_metrics_server():
|
||||
@mock.patch("module_build_service.monitor.builder_success_counter.inc")
|
||||
def test_monitor_state_changing_success(succ_cnt, failed_cnt, db_session):
|
||||
conf = mbs_config.Config(TestConfiguration)
|
||||
b = make_module(db_session, "pkg:0.1:1:c1", requires_list={"platform": "el8"})
|
||||
b = make_module_in_db(
|
||||
"pkg:0.1:1:c1", [{
|
||||
"requires": {"platform": ["el8"]},
|
||||
"buildrequires": {"platform": ["el8"]},
|
||||
}],
|
||||
db_session=db_session)
|
||||
b.transition(db_session, conf, models.BUILD_STATES["wait"])
|
||||
b.transition(db_session, conf, models.BUILD_STATES["build"])
|
||||
b.transition(db_session, conf, models.BUILD_STATES["done"])
|
||||
@@ -85,7 +90,12 @@ def test_monitor_state_changing_success(succ_cnt, failed_cnt, db_session):
|
||||
def test_monitor_state_changing_failure(succ_cnt, failed_cnt, db_session):
|
||||
failure_type = "user"
|
||||
conf = mbs_config.Config(TestConfiguration)
|
||||
b = make_module(db_session, "pkg:0.1:1:c1", requires_list={"platform": "el8"})
|
||||
b = make_module_in_db(
|
||||
"pkg:0.1:1:c1", [{
|
||||
"requires": {"platform": ["el8"]},
|
||||
"buildrequires": {"platform": ["el8"]},
|
||||
}],
|
||||
db_session=db_session)
|
||||
b.transition(db_session, conf, models.BUILD_STATES["wait"])
|
||||
b.transition(db_session, conf, models.BUILD_STATES["build"])
|
||||
b.transition(db_session, conf, models.BUILD_STATES["failed"], failure_type=failure_type)
|
||||
|
||||
Reference in New Issue
Block a user