aboutsummaryrefslogtreecommitdiff
path: root/tests/test_something.py
blob: 8091f46e763d4f7eb0ffc59c1002f2186f1ba645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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)