From 79a2a5fda64a68decb278a460f44a62e46b5a145 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 7 Aug 2023 14:39:11 +0200 Subject: [PATCH 1/3] tests: Unset OSC_CONFIG env during tearDown() --- tests/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/common.py b/tests/common.py index 0cc88fe02b..e4c58dcc84 100644 --- a/tests/common.py +++ b/tests/common.py @@ -220,6 +220,7 @@ def tearDown(self): shutil.rmtree(self.tmpdir) except: pass + os.environ.pop("OSC_CONFIG", "") self.assertTrue(len(EXPECTED_REQUESTS) == 0) def _get_fixtures_dir(self): From a5816132c758e5a3689b819a464336a9eaee59b5 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 7 Aug 2023 14:40:05 +0200 Subject: [PATCH 2/3] tests: Fix TestConf to load oscrc from fixtures --- tests/test_conf.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_conf.py b/tests/test_conf.py index acea83472e..0573cfa625 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -1,9 +1,13 @@ import importlib +import os import unittest import osc.conf +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "conf_fixtures") + + class TestConf(unittest.TestCase): def setUp(self): # reset the global `config` in preparation for running the tests @@ -13,6 +17,9 @@ def tearDown(self): # reset the global `config` to avoid impacting tests from other classes importlib.reload(osc.conf) + def _get_fixtures_dir(self): + return FIXTURES_DIR + def test_bool_opts_defaults(self): config = osc.conf.config for opt in osc.conf._boolean_opts: @@ -28,7 +35,8 @@ def test_int_opts_defaults(self): self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'") def test_bool_opts(self): - osc.conf.get_config() + oscrc = os.path.join(self._get_fixtures_dir(), "oscrc") + osc.conf.get_config(override_conffile=oscrc, override_no_keyring=True) config = osc.conf.config for opt in osc.conf._boolean_opts: if opt not in config: @@ -36,7 +44,8 @@ def test_bool_opts(self): self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'") def test_int_opts(self): - osc.conf.get_config() + oscrc = os.path.join(self._get_fixtures_dir(), "oscrc") + osc.conf.get_config(override_conffile=oscrc, override_no_keyring=True) config = osc.conf.config for opt in osc.conf._integer_opts: if opt not in config: From 7ad815a1494216856574a3b895176780b827ba3e Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 9 Aug 2023 13:07:06 +0200 Subject: [PATCH 3/3] tests: Fix TestMirrorGroup to load oscrc from fixtures --- tests/test_grabber.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_grabber.py b/tests/test_grabber.py index 6cad5a1b1f..f88cd87266 100644 --- a/tests/test_grabber.py +++ b/tests/test_grabber.py @@ -7,12 +7,16 @@ import osc.grabber as osc_grabber +FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "conf_fixtures") + + class TestMirrorGroup(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp(prefix='osc_test') # reset the global `config` in preparation for running the tests importlib.reload(osc.conf) - osc.conf.get_config() + oscrc = os.path.join(self._get_fixtures_dir(), "oscrc") + osc.conf.get_config(override_conffile=oscrc, override_no_keyring=True) def tearDown(self): # reset the global `config` to avoid impacting tests from other classes @@ -22,6 +26,9 @@ def tearDown(self): except: pass + def _get_fixtures_dir(self): + return FIXTURES_DIR + def test_invalid_scheme(self): gr = osc_grabber.OscFileGrabber() mg = osc_grabber.OscMirrorGroup(gr, ["container://example.com"])