1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00
github.com_openSUSE_osc/tests/test_config_parser.py

50 lines
1.0 KiB
Python

import configparser
import unittest
from osc.OscConfigParser import OscConfigParser
class TestOscConfigParser(unittest.TestCase):
def setUp(self):
self.parser = OscConfigParser()
self.parser.read_string("""
[general]
apiurl = http://localhost
[http://localhost]
credentials_mgr_class=
user=
pass=
""")
def test_disabled_interpolation(self):
# with interpolation on, this would raise
# ValueError: invalid interpolation syntax in '%' at position 0
self.parser.set("http://localhost", "pass", "%")
def test_duplicate_section(self):
conf = """
[general]
[http://localhost]
[http://localhost]
"""
parser = OscConfigParser()
self.assertRaises(configparser.DuplicateSectionError, parser.read_string, conf)
def test_duplicate_option(self):
conf = """
[general]
[http://localhost]
user=
user=
"""
parser = OscConfigParser()
self.assertRaises(configparser.DuplicateOptionError, parser.read_string, conf)
if __name__ == "__main__":
unittest.main()