-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test for _get_recipe_info function
- Loading branch information
1 parent
ae4fe53
commit a4fd67d
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<job id="8874545" owner="mrack" result="Pass" status="Completed" retention_tag="audit" product="[internal]"><whiteboard>This job has been created using mrack.</whiteboard><recipeSet priority="Normal" response="ack" id="13149276"><recipe id="15482633" job_id="8874545" result="Pass" status="Completed" system="test.example.com"> <logs><log href="https://test.example.com/logs/console.log" name="console.log"/> <log href="https://test.example.com/logs/anaconda.log" name="anaconda.log"/></logs></recipe></recipeSet></job> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2021 Red Hat Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Tests for mrack.providers.beaker""" | ||
|
||
from unittest import mock | ||
from unittest.mock import Mock, patch | ||
|
||
import pytest | ||
|
||
from mrack.providers.beaker import BeakerProvider | ||
|
||
from .utils import get_content | ||
|
||
|
||
class TestBeakerProvider: | ||
def setup_method(self): | ||
|
||
self.mock_hub = Mock() | ||
self.result_xml = get_content("result.xml") | ||
self.mock_hub.taskactions.to_xml = Mock(return_value=self.result_xml) | ||
self.mock_hub_class = Mock(return_value=self.mock_hub) | ||
self.hub_patcher = patch( | ||
"mrack.providers.beaker.HubProxy", new=self.mock_hub_class | ||
) | ||
self.hub_patcher.start() | ||
self.log_msg_start = "Beaker [client.testdomain.test]" | ||
self.beaker_id = 8874545 | ||
self.distros = ["Fedora-32%", "Fedora-37%", "CentOS-Stream-9%"] | ||
self.timeout = 120 | ||
self.reserve_duration = 86400 | ||
|
||
def teardown_method(self): | ||
mock.patch.stopall() | ||
|
||
@pytest.mark.asyncio | ||
async def test_get_repo_info(self): | ||
provider = BeakerProvider() | ||
await provider.init(self.distros, self.timeout, self.reserve_duration) | ||
bkr_res = provider._get_recipe_info(self.beaker_id, self.log_msg_start) | ||
assert bkr_res["system"] == "test.example.com" | ||
assert bkr_res["status"] == "Completed" | ||
assert bkr_res["result"] == "Pass" | ||
assert bkr_res["rid"] == "15482633" | ||
assert bkr_res["id"] == "8874545" | ||
assert bkr_res["logs"] == { | ||
"console.log": "https://test.example.com/logs/console.log", | ||
"anaconda.log": "https://test.example.com/logs/anaconda.log", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters