21
21
@pytest .mark .describe ("Device Client Reported Properties" )
22
22
class TestReportedProperties (object ):
23
23
@pytest .mark .it ("Can set a simple reported property" )
24
- async def test_simple_patch (self , client , reported_props , get_next_reported_patch_arrival ):
24
+ async def test_simple_patch (
25
+ self , client , random_reported_props , get_next_reported_patch_arrival
26
+ ):
25
27
26
28
# patch properties
27
- await client .patch_twin_reported_properties (reported_props )
29
+ await client .patch_twin_reported_properties (random_reported_props )
28
30
29
31
# wait for patch to arrive at service and verify
30
32
received_patch = await get_next_reported_patch_arrival ()
31
33
assert (
32
- received_patch [const .REPORTED ][const .TEST_CONTENT ] == reported_props [const .TEST_CONTENT ]
34
+ received_patch [const .REPORTED ][const .TEST_CONTENT ]
35
+ == random_reported_props [const .TEST_CONTENT ]
33
36
)
34
37
35
38
# get twin from the service and verify content
36
39
twin = await client .get_twin ()
37
- assert twin [const .REPORTED ][const .TEST_CONTENT ] == reported_props [const .TEST_CONTENT ]
40
+ assert twin [const .REPORTED ][const .TEST_CONTENT ] == random_reported_props [const .TEST_CONTENT ]
38
41
39
42
@pytest .mark .it ("Can clear a reported property" )
40
- async def test_clear_property (self , client , reported_props , get_next_reported_patch_arrival ):
43
+ async def test_clear_property (
44
+ self , client , random_reported_props , get_next_reported_patch_arrival
45
+ ):
41
46
42
47
# patch properties and verify that the service received the patch
43
- await client .patch_twin_reported_properties (reported_props )
48
+ await client .patch_twin_reported_properties (random_reported_props )
44
49
received_patch = await get_next_reported_patch_arrival ()
45
50
assert (
46
- received_patch [const .REPORTED ][const .TEST_CONTENT ] == reported_props [const .TEST_CONTENT ]
51
+ received_patch [const .REPORTED ][const .TEST_CONTENT ]
52
+ == random_reported_props [const .TEST_CONTENT ]
47
53
)
48
54
49
55
# send a patch clearing properties and verify that the service received that patch
@@ -60,22 +66,23 @@ async def test_clear_property(self, client, reported_props, get_next_reported_pa
60
66
61
67
@pytest .mark .it ("Connects the transport if necessary" )
62
68
async def test_connect_if_necessary (
63
- self , client , reported_props , get_next_reported_patch_arrival
69
+ self , client , random_reported_props , get_next_reported_patch_arrival
64
70
):
65
71
66
72
await client .disconnect ()
67
73
68
74
assert not client .connected
69
- await client .patch_twin_reported_properties (reported_props )
75
+ await client .patch_twin_reported_properties (random_reported_props )
70
76
assert client .connected
71
77
72
78
received_patch = await get_next_reported_patch_arrival ()
73
79
assert (
74
- received_patch [const .REPORTED ][const .TEST_CONTENT ] == reported_props [const .TEST_CONTENT ]
80
+ received_patch [const .REPORTED ][const .TEST_CONTENT ]
81
+ == random_reported_props [const .TEST_CONTENT ]
75
82
)
76
83
77
84
twin = await client .get_twin ()
78
- assert twin [const .REPORTED ][const .TEST_CONTENT ] == reported_props [const .TEST_CONTENT ]
85
+ assert twin [const .REPORTED ][const .TEST_CONTENT ] == random_reported_props [const .TEST_CONTENT ]
79
86
80
87
81
88
@pytest .mark .dropped_connection
@@ -89,13 +96,15 @@ def extra_client_kwargs(self):
89
96
90
97
@pytest .mark .it ("Sends if connection drops before sending" )
91
98
async def test_sends_if_drop_before_sending (
92
- self , client , reported_props , dropper , get_next_reported_patch_arrival
99
+ self , client , random_reported_props , dropper , get_next_reported_patch_arrival
93
100
):
94
101
95
102
assert client .connected
96
103
dropper .drop_outgoing ()
97
104
98
- send_task = asyncio .create_task (client .patch_twin_reported_properties (reported_props ))
105
+ send_task = asyncio .create_task (
106
+ client .patch_twin_reported_properties (random_reported_props )
107
+ )
99
108
while client .connected :
100
109
await asyncio .sleep (1 )
101
110
@@ -109,18 +118,21 @@ async def test_sends_if_drop_before_sending(
109
118
110
119
received_patch = await get_next_reported_patch_arrival ()
111
120
assert (
112
- received_patch [const .REPORTED ][const .TEST_CONTENT ] == reported_props [const .TEST_CONTENT ]
121
+ received_patch [const .REPORTED ][const .TEST_CONTENT ]
122
+ == random_reported_props [const .TEST_CONTENT ]
113
123
)
114
124
115
125
@pytest .mark .it ("Sends if connection rejects send" )
116
126
async def test_sends_if_reject_before_sending (
117
- self , client , reported_props , dropper , get_next_reported_patch_arrival
127
+ self , client , random_reported_props , dropper , get_next_reported_patch_arrival
118
128
):
119
129
120
130
assert client .connected
121
131
dropper .reject_outgoing ()
122
132
123
- send_task = asyncio .create_task (client .patch_twin_reported_properties (reported_props ))
133
+ send_task = asyncio .create_task (
134
+ client .patch_twin_reported_properties (random_reported_props )
135
+ )
124
136
while client .connected :
125
137
await asyncio .sleep (1 )
126
138
@@ -134,7 +146,8 @@ async def test_sends_if_reject_before_sending(
134
146
135
147
received_patch = await get_next_reported_patch_arrival ()
136
148
assert (
137
- received_patch [const .REPORTED ][const .TEST_CONTENT ] == reported_props [const .TEST_CONTENT ]
149
+ received_patch [const .REPORTED ][const .TEST_CONTENT ]
150
+ == random_reported_props [const .TEST_CONTENT ]
138
151
)
139
152
140
153
0 commit comments