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:
Chenxiong Qi
2019-07-21 22:46:46 +08:00
parent 68fe2b69f1
commit 5017fbae7f
13 changed files with 359 additions and 211 deletions

View File

@@ -42,9 +42,7 @@ class TestDBModule:
import_mmd(db_session, mmd)
platform_f300103 = db_session.query(ModuleBuild).filter_by(stream="f30.1.3").one()
mmd = tests.make_module(db_session,
"testmodule:master:20170109091357:123",
store_to_db=False)
mmd = tests.make_module("testmodule:master:20170109091357:123")
build = ModuleBuild(
name="testmodule",
stream="master",

View File

@@ -380,7 +380,7 @@ class TestMBSModule:
"version": 1,
"context": "c1",
"modulemd": mmd_to_str(
tests.make_module(db_session, "nodejs:10:1:c1", store_to_db=False),
tests.make_module("nodejs:10:1:c1"),
),
},
{
@@ -389,7 +389,7 @@ class TestMBSModule:
"version": 2,
"context": "c1",
"modulemd": mmd_to_str(
tests.make_module(db_session, "nodejs:10:2:c1", store_to_db=False),
tests.make_module("nodejs:10:2:c1"),
),
},
],