Merge #1340 Added an REST endpoint to display log messages

This commit is contained in:
Jan Kaluža
2019-07-31 12:49:03 +00:00
6 changed files with 190 additions and 10 deletions

View File

@@ -867,7 +867,8 @@ class TestKojiBuilder:
],
)
current_module = module_build_service.models.ModuleBuild.get_by_id(db_session, 3)
rv = KojiModuleBuilder._get_filtered_rpms_on_self_dep(current_module, br_filtered_rpms)
with patch.object(module_build_service.models.ModuleBuild, 'log_message'):
rv = KojiModuleBuilder._get_filtered_rpms_on_self_dep(current_module, br_filtered_rpms)
assert set(rv) == set(expected)
session.assert_not_called()

View File

@@ -2741,3 +2741,39 @@ class TestViews:
'You cannot specify the parameter "reuse_components_from" when the "rebuild_strategy" '
'parameter is set to "all"'
)
class TestLogMessageViews:
def setup_method(self, test_method):
self.client = app.test_client()
init_data(2)
self.module_id = 2
self.component_id = 1
self.module_build = db.session.query(ModuleBuild).filter_by(id=self.module_id).first()
self.module_build.log_message(db.session, "Build-1 msg")
self.module_build.log_message(db.session, "Build-2 msg")
self.component_build = self.module_build.component_builds[0]
self.component_build.log_message(db.session, "Component-1 msg")
def test_view_log_messages_for_module_builds(self):
url = "/module-build-service/1/module-builds/{module_id}/messages".format(
module_id=self.module_id)
res = self.client.get(url)
json_res = str(res.data)
assert "Build-1" in json_res
assert "Build-2" in json_res
assert "Component-1" in json_res
def test_view_log_messages_for_component_builds(self):
url = "/module-build-service/1/component-builds/{component_id}/messages".format(
component_id=self.component_id)
res = self.client.get(url)
json_res = str(res.data)
assert "Build-1" not in json_res
assert "Build-2" not in json_res
assert "Component-1" in json_res