Skip to content

Commit

Permalink
WIP - fix tests. repofile moved from sub-man to rhsm
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard committed Aug 2, 2024
1 parent 7ca91fb commit 0f6741a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/cli_command/test_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def test_set_repo_status_enable_all_disable_all(self, mock_repolib):
self.cc.cp.setContentOverrides.assert_called_once_with("fake_id", match_dict_list)
self.assertTrue(repolib_instance.update.called)

@patch("subscription_manager.repofile.RepoFileBase.path_exists")
@patch("rhsm.repofile.RepoFileBase.path_exists")
@patch("subscription_manager.cli_command.repos.YumRepoFile")
def test_set_repo_status_when_disconnected(self, mock_repofile, mock_path_exists):
mock_path_exists.return_value = True
Expand Down
32 changes: 16 additions & 16 deletions test/test_repolib.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
from iniparse import ConfigParser

import rhsm.connection
from subscription_manager import repofile
from rhsm import repofile

# repofile must be patched and reloaded to import AptRepofile, otherwise
# the class is not defined in the first place
deb_mock = MagicMock()
deb_mock.Deb822 = dict
with patch.dict("subscription_manager.repofile.sys.modules", {"debian.deb822": deb_mock}):
with patch.dict("rhsm.repofile.sys.modules", {"debian.deb822": deb_mock}):
reload(repofile)
from subscription_manager.repofile import AptRepoFile
from rhsm.repofile import AptRepoFile
reload(repofile)

from .stubs import (
Expand All @@ -52,7 +52,7 @@
YumReleaseverSource,
YumPluginManager,
)
from subscription_manager.repofile import Repo, TidyWriter, YumRepoFile
from rhsm.repofile import Repo, TidyWriter, YumRepoFile
from subscription_manager import injection as inj
from rhsm.config import RhsmConfigParser
from rhsmlib.services import config
Expand Down Expand Up @@ -908,13 +908,13 @@ def test_releasever_the_string_none(self):

class AptRepoFileTest(unittest.TestCase):
def _helper_stub_repo(self, *args, **kwargs):
with patch("subscription_manager.repofile.HAS_DEB822", True):
with patch("rhsm.repofile.apt", True):
repo = Repo(*args, **kwargs)
return repo

def _helper_stub_repofile(self, *args, **kwargs):
my_mock = MagicMock()
with patch("subscription_manager.repofile.RepoFileBase.create", my_mock):
with patch("rhsm.repofile.RepoFileBase.create", my_mock):
repofile = AptRepoFile(*args, **kwargs)
return repofile

Expand Down Expand Up @@ -1092,8 +1092,8 @@ def test_fix_content_arches_multi(self, mock_file):


class YumRepoFileTest(unittest.TestCase):
@patch("subscription_manager.repofile.YumRepoFile.create")
@patch("subscription_manager.repofile.TidyWriter")
@patch("rhsm.repofile.YumRepoFile.create")
@patch("rhsm.repofile.TidyWriter")
def test_configparsers_equal(self, tidy_writer, stub_create):
rf = YumRepoFile()
other = RawConfigParser()
Expand All @@ -1102,8 +1102,8 @@ def test_configparsers_equal(self, tidy_writer, stub_create):
parser.set("test", "key", "val")
self.assertTrue(rf._configparsers_equal(other))

@patch("subscription_manager.repofile.YumRepoFile.create")
@patch("subscription_manager.repofile.TidyWriter")
@patch("rhsm.repofile.YumRepoFile.create")
@patch("rhsm.repofile.TidyWriter")
def test_configparsers_diff_sections(self, tidy_writer, stub_create):
rf = YumRepoFile()
rf.add_section("new_section")
Expand All @@ -1113,8 +1113,8 @@ def test_configparsers_diff_sections(self, tidy_writer, stub_create):
parser.set("test", "key", "val")
self.assertFalse(rf._configparsers_equal(other))

@patch("subscription_manager.repofile.YumRepoFile.create")
@patch("subscription_manager.repofile.TidyWriter")
@patch("rhsm.repofile.YumRepoFile.create")
@patch("rhsm.repofile.TidyWriter")
def test_configparsers_diff_item_val(self, tidy_writer, stub_create):
rf = YumRepoFile()
other = RawConfigParser()
Expand All @@ -1124,8 +1124,8 @@ def test_configparsers_diff_item_val(self, tidy_writer, stub_create):
rf.set("test", "key", "val2")
self.assertFalse(rf._configparsers_equal(other))

@patch("subscription_manager.repofile.YumRepoFile.create")
@patch("subscription_manager.repofile.TidyWriter")
@patch("rhsm.repofile.YumRepoFile.create")
@patch("rhsm.repofile.TidyWriter")
def test_configparsers_diff_items(self, tidy_writer, stub_create):
rf = YumRepoFile()
other = RawConfigParser()
Expand All @@ -1135,8 +1135,8 @@ def test_configparsers_diff_items(self, tidy_writer, stub_create):
rf.set("test", "somekey", "val")
self.assertFalse(rf._configparsers_equal(other))

@patch("subscription_manager.repofile.YumRepoFile.create")
@patch("subscription_manager.repofile.TidyWriter")
@patch("rhsm.repofile.YumRepoFile.create")
@patch("rhsm.repofile.TidyWriter")
def test_configparsers_equal_int(self, tidy_writer, stub_create):
rf = YumRepoFile()
other = RawConfigParser()
Expand Down

0 comments on commit 0f6741a

Please sign in to comment.