Skip to content

Commit 535f3ae

Browse files
committed
add test case for ids in get_state methods
1 parent d48cbcc commit 535f3ae

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

tests/test_entity_formatter.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,44 @@ def test_write_thing_with_location(self):
5353
entity_json = frost_sta_client.utils.transform_entity_to_json_dict(entity)
5454
self.assertDictEqual(result, entity_json)
5555

56+
57+
def test_write_thing_with_specified_id_and_attributes(self):
58+
result = {'@iot.id': 123,
59+
'name': 'another nice thing',
60+
'Locations': [
61+
{
62+
'@iot.id': 456,
63+
'name': 'location with specified id'
64+
}
65+
],
66+
'HistoricalLocations': [
67+
{
68+
'@iot.id': 789
69+
}
70+
],
71+
'Datastreams': [
72+
{
73+
'name': 'Datastream without specified id'
74+
}
75+
],
76+
}
77+
entity = frost_sta_client.model.thing.Thing(id=123)
78+
entity.name = 'another nice thing'
79+
80+
location = frost_sta_client.model.location.Location(name='location with specified id')
81+
location.id = 456
82+
historical_location = frost_sta_client.model.historical_location.HistoricalLocation(id=789)
83+
datastream = frost_sta_client.model.datastream.Datastream(name='Datastream without specified id')
84+
85+
entity.locations = frost_sta_client.model.ext.entity_list.EntityList(entities=[location],
86+
entity_class=entity_type.EntityTypes['Location']['class'])
87+
entity.historical_locations = frost_sta_client.model.ext.entity_list.EntityList(entities=[historical_location],
88+
entity_class=entity_type.EntityTypes['HistoricalLocation']['class'])
89+
entity.datastreams = frost_sta_client.model.ext.entity_list.EntityList(entities=[datastream], entity_class=entity_type.EntityTypes['Datastream']['class'])
90+
entity_json = frost_sta_client.utils.transform_entity_to_json_dict(entity)
91+
self.assertDictEqual(result, entity_json)
92+
93+
5694
def test_incorrect_collection(self):
5795
exp_result = {
5896
'name': 'test thing',

0 commit comments

Comments
 (0)