mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-24 03:02:12 +01:00
Merge pull request #1378 from dmach/fix-tests-oscrc
Fix (lack of) loading oscrc in tests
This commit is contained in:
commit
391abc26a0
@ -220,6 +220,7 @@ class OscTestCase(unittest.TestCase):
|
|||||||
shutil.rmtree(self.tmpdir)
|
shutil.rmtree(self.tmpdir)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
os.environ.pop("OSC_CONFIG", "")
|
||||||
self.assertTrue(len(EXPECTED_REQUESTS) == 0)
|
self.assertTrue(len(EXPECTED_REQUESTS) == 0)
|
||||||
|
|
||||||
def _get_fixtures_dir(self):
|
def _get_fixtures_dir(self):
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import importlib
|
import importlib
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import osc.conf
|
import osc.conf
|
||||||
|
|
||||||
|
|
||||||
|
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "conf_fixtures")
|
||||||
|
|
||||||
|
|
||||||
class TestConf(unittest.TestCase):
|
class TestConf(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# reset the global `config` in preparation for running the tests
|
# reset the global `config` in preparation for running the tests
|
||||||
@ -13,6 +17,9 @@ class TestConf(unittest.TestCase):
|
|||||||
# reset the global `config` to avoid impacting tests from other classes
|
# reset the global `config` to avoid impacting tests from other classes
|
||||||
importlib.reload(osc.conf)
|
importlib.reload(osc.conf)
|
||||||
|
|
||||||
|
def _get_fixtures_dir(self):
|
||||||
|
return FIXTURES_DIR
|
||||||
|
|
||||||
def test_bool_opts_defaults(self):
|
def test_bool_opts_defaults(self):
|
||||||
config = osc.conf.config
|
config = osc.conf.config
|
||||||
for opt in osc.conf._boolean_opts:
|
for opt in osc.conf._boolean_opts:
|
||||||
@ -28,7 +35,8 @@ class TestConf(unittest.TestCase):
|
|||||||
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
self.assertIsInstance(config[opt], int, msg=f"option: '{opt}'")
|
||||||
|
|
||||||
def test_bool_opts(self):
|
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
|
config = osc.conf.config
|
||||||
for opt in osc.conf._boolean_opts:
|
for opt in osc.conf._boolean_opts:
|
||||||
if opt not in config:
|
if opt not in config:
|
||||||
@ -36,7 +44,8 @@ class TestConf(unittest.TestCase):
|
|||||||
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
self.assertIsInstance(config[opt], bool, msg=f"option: '{opt}'")
|
||||||
|
|
||||||
def test_int_opts(self):
|
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
|
config = osc.conf.config
|
||||||
for opt in osc.conf._integer_opts:
|
for opt in osc.conf._integer_opts:
|
||||||
if opt not in config:
|
if opt not in config:
|
||||||
|
@ -7,12 +7,16 @@ import osc.conf
|
|||||||
import osc.grabber as osc_grabber
|
import osc.grabber as osc_grabber
|
||||||
|
|
||||||
|
|
||||||
|
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), "conf_fixtures")
|
||||||
|
|
||||||
|
|
||||||
class TestMirrorGroup(unittest.TestCase):
|
class TestMirrorGroup(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.tmpdir = tempfile.mkdtemp(prefix='osc_test')
|
self.tmpdir = tempfile.mkdtemp(prefix='osc_test')
|
||||||
# reset the global `config` in preparation for running the tests
|
# reset the global `config` in preparation for running the tests
|
||||||
importlib.reload(osc.conf)
|
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):
|
def tearDown(self):
|
||||||
# reset the global `config` to avoid impacting tests from other classes
|
# reset the global `config` to avoid impacting tests from other classes
|
||||||
@ -22,6 +26,9 @@ class TestMirrorGroup(unittest.TestCase):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _get_fixtures_dir(self):
|
||||||
|
return FIXTURES_DIR
|
||||||
|
|
||||||
def test_invalid_scheme(self):
|
def test_invalid_scheme(self):
|
||||||
gr = osc_grabber.OscFileGrabber()
|
gr = osc_grabber.OscFileGrabber()
|
||||||
mg = osc_grabber.OscMirrorGroup(gr, ["container://example.com"])
|
mg = osc_grabber.OscMirrorGroup(gr, ["container://example.com"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user