def test_to_json(self): import json sh = MockSmartHome() conf = {'type': 'num', 'eval': '2'} item = lib.item.Item(config=conf, parent=sh, smarthome=sh, path='test_item01') item.set('42') expected = json.dumps({'attributes': {}, 'value': 42, 'type': 'num', 'children': [], 'id': 'test_item01', 'name': 'test_item01'}, sort_keys=True, indent=2) self.assertEqual(item.to_json(), expected)