diff options
author | romangraef <romangraef@loves.dicksinhisan.us> | 2018-07-06 10:35:54 +0200 |
---|---|---|
committer | romangraef <romangraef@loves.dicksinhisan.us> | 2018-07-06 10:35:54 +0200 |
commit | cbb9f2c3622ec96caf4ec9e58e84c8fbd3f45d23 (patch) | |
tree | bfe6aa26d7cab12334ae79b353ba2ec365f2b582 /tests/test_something.py | |
download | configlib-cbb9f2c3622ec96caf4ec9e58e84c8fbd3f45d23.tar.gz configlib-cbb9f2c3622ec96caf4ec9e58e84c8fbd3f45d23.tar.bz2 configlib-cbb9f2c3622ec96caf4ec9e58e84c8fbd3f45d23.zip |
Initial commit
Diffstat (limited to 'tests/test_something.py')
-rw-r--r-- | tests/test_something.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_something.py b/tests/test_something.py new file mode 100644 index 0000000..8091f46 --- /dev/null +++ b/tests/test_something.py @@ -0,0 +1,39 @@ +import json +from unittest import TestCase + +from configlib.model_impl import BaseConfig + + +class Yeeah(object): + a: int + + +class SomeConfig(BaseConfig): + something: str + ye: Yeeah + + +test_dict = { + 'something': 'hmm', + 'ye': { + 'a': 1 + } +} + + +def verify_test_dict(conf): + assert conf.something == 'hmm' + assert isinstance(conf, SomeConfig) + assert conf.ye.a == 1 + assert isinstance(conf.ye, Yeeah) + + +class TestSomething(TestCase): + + def test_yeah(self): + conf: SomeConfig = SomeConfig.parse_dict(test_dict) + verify_test_dict(conf) + + def test_text(self): + conf: SomeConfig = SomeConfig.loads(json.dumps(test_dict)) + verify_test_dict(conf) |