mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-23 18:21:42 +08:00
unit tests
This commit is contained in:
@@ -17,7 +17,7 @@ from module_build_service.common.utils import (mmd_to_str, load_mmd,
|
||||
from module_build_service.scheduler.db_session import db_session
|
||||
from module_build_service.web.submit import (
|
||||
get_prefixed_version, submit_module_build, submit_module_build_from_yaml,
|
||||
process_module_context_configuration
|
||||
process_module_context_configuration, _apply_side_tag,
|
||||
)
|
||||
from tests import (
|
||||
scheduler_init_data,
|
||||
@@ -218,6 +218,53 @@ class TestProcessModuleContextConfiguration:
|
||||
assert stream.is_static_context()
|
||||
|
||||
|
||||
class TestApplySideTag:
|
||||
def get_mmd(self):
|
||||
yaml_str = """
|
||||
document: modulemd
|
||||
version: 2
|
||||
data:
|
||||
name: app
|
||||
stream: test
|
||||
summary: "A test module"
|
||||
description: >
|
||||
"A test module stream"
|
||||
license:
|
||||
module: [ MIT ]
|
||||
dependencies:
|
||||
- buildrequires:
|
||||
platform: []
|
||||
gtk: []
|
||||
requires:
|
||||
platform: []
|
||||
gtk: []
|
||||
"""
|
||||
return load_mmd(yaml_str)
|
||||
|
||||
def test_apply_side_tag(self):
|
||||
"""
|
||||
Test that the side tag option is correctly added into the xmd
|
||||
"""
|
||||
mmd = self.get_mmd()
|
||||
side_tag = "SIDETAG"
|
||||
_apply_side_tag(mmd, {"side_tag": side_tag})
|
||||
|
||||
xmd = mmd.get_xmd()
|
||||
assert xmd["mbs"]["side_tag"] == side_tag
|
||||
|
||||
def test_apply_side_tag_no_option(self):
|
||||
"""
|
||||
Test that the xmd is unchanged when option not given
|
||||
"""
|
||||
mmd = self.get_mmd()
|
||||
xmd_orig = mmd.get_xmd()
|
||||
_apply_side_tag(mmd, {})
|
||||
|
||||
xmd = mmd.get_xmd()
|
||||
assert xmd == xmd_orig
|
||||
assert "side_tag" not in xmd.get("mbs", {})
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("reuse_component_init_data")
|
||||
class TestUtilsComponentReuse:
|
||||
@mock.patch("module_build_service.web.submit.submit_module_build")
|
||||
|
||||
Reference in New Issue
Block a user