Support for mutable and immutable configurations
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
from src.config_parser.json import JSONConfiguration
|
||||
from src.config_parser.exceptions import JSONObjectSyntaxError, JSONValueSyntaxError, JSONStringSyntaxError, JSONArraySyntaxError, EscapeSequenceSyntaxError
|
||||
from src.config_parser import set_mutability
|
||||
|
||||
def test_json_configuration():
|
||||
# Test valid JSON configuration parsing
|
||||
@@ -220,4 +221,26 @@ def test_json_configuration():
|
||||
JSONConfiguration.from_string('')
|
||||
assert False, 'Excepted JSONValueSyntaxError'
|
||||
except JSONValueSyntaxError:
|
||||
pass
|
||||
|
||||
def test_mutability():
|
||||
config = JSONConfiguration(mutable=False)
|
||||
try:
|
||||
config.key = 'value'
|
||||
assert False, 'Expected TypeError'
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
set_mutability(config, True)
|
||||
assert config._mutable == True
|
||||
|
||||
config.key = 'value'
|
||||
|
||||
set_mutability(config, False)
|
||||
assert config._mutable == False
|
||||
|
||||
try:
|
||||
del config.key
|
||||
assert False, 'Expected TypeError'
|
||||
except TypeError:
|
||||
pass
|
||||
Reference in New Issue
Block a user