def test_deepcopy(): """Test DotDict""" dic = u.DotDict(id="1", info={ 'path': 'test.txt', 'type': 'txt', 'view': 'text' }) assert type(dic) == u.DotDict assert getattr(dic, 'id') assert getattr(dic, 'info') assert hasattr(dic, 'lookup') assert callable(getattr(dic, 'lookup')) assert type(dic.info) == u.DotDict assert getattr(dic.info, 'path') assert getattr(dic.info, 'type') assert getattr(dic.info, 'view') cp = deepcopy(dic) assert type(cp) == u.DotDict assert getattr(cp, 'id') assert getattr(cp, 'info') assert hasattr(cp, 'lookup') assert callable(getattr(cp, 'lookup')) assert type(cp.info) == u.DotDict assert getattr(cp.info, 'path') assert getattr(cp.info, 'type') assert getattr(cp.info, 'view')
def test_dot_dict_init(): """Test DotDict""" dic = u.DotDict(id="1", path="test.txt", type="txt", view="text") assert type(dic) == u.DotDict assert getattr(dic, 'id') assert getattr(dic, 'path') assert getattr(dic, 'type') assert getattr(dic, 'view')
def test_lookup_dict_init(): dic = u.DotDict(id="1", path="test.txt", type="txt", view="text") assert type(dic) == u.DotDict assert getattr(dic, 'id') assert getattr(dic, 'path') assert getattr(dic, 'type') assert getattr(dic, 'view') assert hasattr(dic, 'lookup') assert callable(getattr(dic, 'lookup')) assert dic.lookup('1') == ['id']
def test_dot_dict_setattr(): """Test DotDict""" dic = u.DotDict() dic.id = '1' dic.path = 'test.txt' dic.type = 'txt' dic.view = 'text' assert getattr(dic, 'id') assert getattr(dic, 'path') assert getattr(dic, 'type') assert getattr(dic, 'view')
def test_dot_dict_of_dict_setattr(): """Test DotDict""" dic = u.DotDict() dic.id = '1' dic.info = {'path': 'test.txt', 'type': 'txt', 'view': 'text'} assert getattr(dic, 'id') assert getattr(dic, 'info') assert type(dic.info) == u.DotDict assert getattr(dic.info, 'path') assert getattr(dic.info, 'type') assert getattr(dic.info, 'view')
def test_dot_dict_setitem(): """Test DotDict""" dic = u.DotDict() assert type(dic) == u.DotDict dic['id'] = '1' dic['path'] = 'test.txt' dic['type'] = 'txt' dic['view'] = 'text' assert getattr(dic, 'id') assert getattr(dic, 'path') assert getattr(dic, 'type') assert getattr(dic, 'view')
def test_lookup_dict_of_dict(): """Test DotDict""" dic = u.DotDict(id="1", info={ 'path': 'test.txt', 'type': 'txt', 'view': 'text' }) assert type(dic) == u.DotDict assert getattr(dic, 'id') assert getattr(dic, 'info') assert hasattr(dic, 'lookup') assert callable(getattr(dic, 'lookup')) assert type(dic.info) == u.DotDict assert getattr(dic.info, 'path') assert getattr(dic.info, 'type') assert getattr(dic.info, 'view') assert dic.lookup('txt') == ['info.type']