@@ -79,33 +79,37 @@ def test_dash_stateful_app_client_contract(client):
79
79
80
80
# set the initial expected state
81
81
expected_state = {'inp1' : {'n_clicks' : 0 , 'n_clicks_timestamp' : 1611733453854 },
82
- 'inp2' : {'n_clicks' : 5 , 'n_clicks_timestamp' : 1611733454354 },
82
+ 'inp1b' : {'n_clicks' : 5 , 'n_clicks_timestamp' : 1611733454354 },
83
+ 'inp2' : {'n_clicks' : 7 , 'n_clicks_timestamp' : 1611733454554 },
83
84
'out1-0' : {'n_clicks' : 1 , 'n_clicks_timestamp' : 1611733453954 },
84
85
'out1-1' : {'n_clicks' : 2 , 'n_clicks_timestamp' : 1611733454054 },
85
86
'out1-2' : {'n_clicks' : 3 , 'n_clicks_timestamp' : 1611733454154 },
86
87
'out1-3' : {'n_clicks' : 4 , 'n_clicks_timestamp' : 1611733454254 },
87
- 'out2-0' : {'n_clicks' : 6 , 'n_clicks_timestamp' : 1611733454454 },
88
- 'out3' : {'n_clicks' : 10 , 'n_clicks_timestamp' : 1611733454854 },
89
- 'out4' : {'n_clicks' : 14 , 'n_clicks_timestamp' : 1611733455254 },
90
- 'out5' : {'n_clicks' : 18 , 'n_clicks_timestamp' : 1611733455654 },
91
- '{"_id":"inp-0","_type":"btn3"}' : {'n_clicks' : 7 ,
92
- 'n_clicks_timestamp' : 1611733454554 },
93
- '{"_id":"inp-0","_type":"btn4"}' : {'n_clicks' : 11 ,
94
- 'n_clicks_timestamp' : 1611733454954 },
95
- '{"_id":"inp-0","_type":"btn5"}' : {'n_clicks' : 15 ,
96
- 'n_clicks_timestamp' : 1611733455354 },
97
- '{"_id":"inp-1","_type":"btn3"}' : {'n_clicks' : 8 ,
98
- 'n_clicks_timestamp' : 1611733454654 },
99
- '{"_id":"inp-1","_type":"btn4"}' : {'n_clicks' : 12 ,
100
- 'n_clicks_timestamp' : 1611733455054 },
101
- '{"_id":"inp-1","_type":"btn5"}' : {'n_clicks' : 16 ,
102
- 'n_clicks_timestamp' : 1611733455454 },
103
- '{"_id":"inp-2","_type":"btn3"}' : {'n_clicks' : 9 ,
88
+ 'out1b' : {'href' : 'http://www.example.com/null' ,
89
+ 'n_clicks' : 6 ,
90
+ 'n_clicks_timestamp' : 1611733454454 },
91
+ 'out2-0' : {'n_clicks' : 8 , 'n_clicks_timestamp' : 1611733454654 },
92
+ 'out3' : {'n_clicks' : 12 , 'n_clicks_timestamp' : 1611733455054 },
93
+ 'out4' : {'n_clicks' : 16 , 'n_clicks_timestamp' : 1611733455454 },
94
+ 'out5' : {'n_clicks' : 20 , 'n_clicks_timestamp' : 1611733455854 },
95
+ '{"_id":"inp-0","_type":"btn3"}' : {'n_clicks' : 9 ,
104
96
'n_clicks_timestamp' : 1611733454754 },
105
- '{"_id":"inp-2 ","_type":"btn4"}' : {'n_clicks' : 13 ,
97
+ '{"_id":"inp-0 ","_type":"btn4"}' : {'n_clicks' : 13 ,
106
98
'n_clicks_timestamp' : 1611733455154 },
107
- '{"_id":"inp-2","_type":"btn5"}' : {'n_clicks' : 17 ,
108
- 'n_clicks_timestamp' : 1611733455554 }}
99
+ '{"_id":"inp-0","_type":"btn5"}' : {'n_clicks' : 17 ,
100
+ 'n_clicks_timestamp' : 1611733455554 },
101
+ '{"_id":"inp-1","_type":"btn3"}' : {'n_clicks' : 10 ,
102
+ 'n_clicks_timestamp' : 1611733454854 },
103
+ '{"_id":"inp-1","_type":"btn4"}' : {'n_clicks' : 14 ,
104
+ 'n_clicks_timestamp' : 1611733455254 },
105
+ '{"_id":"inp-1","_type":"btn5"}' : {'n_clicks' : 18 ,
106
+ 'n_clicks_timestamp' : 1611733455654 },
107
+ '{"_id":"inp-2","_type":"btn3"}' : {'n_clicks' : 11 ,
108
+ 'n_clicks_timestamp' : 1611733454954 },
109
+ '{"_id":"inp-2","_type":"btn4"}' : {'n_clicks' : 15 ,
110
+ 'n_clicks_timestamp' : 1611733455354 },
111
+ '{"_id":"inp-2","_type":"btn5"}' : {'n_clicks' : 19 ,
112
+ 'n_clicks_timestamp' : 1611733455754 }}
109
113
110
114
########## test state management of the app and conversion of components ids
111
115
# search for state values in dash layout
@@ -122,7 +126,7 @@ def test_dash_stateful_app_client_contract(client):
122
126
123
127
# update an existent state => update current_state
124
128
stateful_a .update_current_state ('{"_id":"inp-2","_type":"btn5"}' , "n_clicks" , 100 )
125
- expected_state ['{"_id":"inp-2","_type":"btn5"}' ] = {'n_clicks' : 100 , 'n_clicks_timestamp' : 1611733455554 }
129
+ expected_state ['{"_id":"inp-2","_type":"btn5"}' ] = {'n_clicks' : 100 , 'n_clicks_timestamp' : 1611733455754 }
126
130
assert stateful_a .current_state () == expected_state
127
131
128
132
assert DashApp .objects .get (instance_name = "Some name" ).current_state () == {}
@@ -170,34 +174,38 @@ def test_dash_stateful_app_client_contract(client):
170
174
stateful_a .handle_current_state ()
171
175
172
176
# check final state has been changed accordingly
173
- final_state = {'inp1' : {'n_clicks' : 1 , 'n_clicks_timestamp' : 1611736145932 },
174
- 'inp2' : {'n_clicks' : 6 , 'n_clicks_timestamp' : 1611736146875 },
177
+ final_state = {'inp1' : {'n_clicks' : 1 , 'n_clicks_timestamp' : 1615103027288 },
178
+ 'inp1b' : {'n_clicks' : 5 , 'n_clicks_timestamp' : 1615103033482 },
179
+ 'inp2' : {'n_clicks' : 8 , 'n_clicks_timestamp' : 1615103036591 },
175
180
'out1-0' : {'n_clicks' : 1 , 'n_clicks_timestamp' : 1611733453954 },
176
181
'out1-1' : {'n_clicks' : 2 , 'n_clicks_timestamp' : 1611733454054 },
177
182
'out1-2' : {'n_clicks' : 3 , 'n_clicks_timestamp' : 1611733454154 },
178
183
'out1-3' : {'n_clicks' : 4 , 'n_clicks_timestamp' : 1611733454254 },
179
- 'out2-0' : {'n_clicks' : 6 , 'n_clicks_timestamp' : 1611733454454 },
180
- 'out3' : {'n_clicks' : 10 , 'n_clicks_timestamp' : 1611733454854 },
181
- 'out4' : {'n_clicks' : 14 , 'n_clicks_timestamp' : 1611733455254 },
182
- 'out5' : {'n_clicks' : 18 , 'n_clicks_timestamp' : 1611733455654 },
183
- '{"_id":"inp-0","_type":"btn3"}' : {'n_clicks' : 8 ,
184
- 'n_clicks_timestamp' : 1611736147644 },
185
- '{"_id":"inp-0","_type":"btn4"}' : {'n_clicks' : 12 ,
186
- 'n_clicks_timestamp' : 1611733454954 },
187
- '{"_id":"inp-0","_type":"btn5"}' : {'n_clicks' : 16 ,
188
- 'n_clicks_timestamp' : 1611733455354 },
189
- '{"_id":"inp-1","_type":"btn3"}' : {'n_clicks' : 9 ,
190
- 'n_clicks_timestamp' : 1611736148172 },
191
- '{"_id":"inp-1","_type":"btn4"}' : {'n_clicks' : 13 ,
192
- 'n_clicks_timestamp' : 1611733455054 },
193
- '{"_id":"inp-1","_type":"btn5"}' : {'n_clicks' : 18 ,
194
- 'n_clicks_timestamp' : 1611733455454 },
195
- '{"_id":"inp-2","_type":"btn3"}' : {'n_clicks' : 10 ,
196
- 'n_clicks_timestamp' : 1611736149140 },
197
- '{"_id":"inp-2","_type":"btn4"}' : {'n_clicks' : 13 ,
184
+ 'out1b' : {'href' : 'http://www.example.com/1615103033482' ,
185
+ 'n_clicks' : 6 ,
186
+ 'n_clicks_timestamp' : 1611733454454 },
187
+ 'out2-0' : {'n_clicks' : 8 , 'n_clicks_timestamp' : 1611733454654 },
188
+ 'out3' : {'n_clicks' : 12 , 'n_clicks_timestamp' : 1611733455054 },
189
+ 'out4' : {'n_clicks' : 16 , 'n_clicks_timestamp' : 1611733455454 },
190
+ 'out5' : {'n_clicks' : 20 , 'n_clicks_timestamp' : 1611733455854 },
191
+ '{"_id":"inp-0","_type":"btn3"}' : {'n_clicks' : 10 ,
192
+ 'n_clicks_timestamp' : 1615103039030 },
193
+ '{"_id":"inp-0","_type":"btn4"}' : {'n_clicks' : 14 ,
198
194
'n_clicks_timestamp' : 1611733455154 },
199
- '{"_id":"inp-2","_type":"btn5"}' : {'n_clicks' : 19 ,
200
- 'n_clicks_timestamp' : 1611733455554 }}
195
+ '{"_id":"inp-0","_type":"btn5"}' : {'n_clicks' : 18 ,
196
+ 'n_clicks_timestamp' : 1611733455554 },
197
+ '{"_id":"inp-1","_type":"btn3"}' : {'n_clicks' : 11 ,
198
+ 'n_clicks_timestamp' : 1615103039496 },
199
+ '{"_id":"inp-1","_type":"btn4"}' : {'n_clicks' : 15 ,
200
+ 'n_clicks_timestamp' : 1611733455254 },
201
+ '{"_id":"inp-1","_type":"btn5"}' : {'n_clicks' : 19 ,
202
+ 'n_clicks_timestamp' : 1611733455654 },
203
+ '{"_id":"inp-2","_type":"btn3"}' : {'n_clicks' : 12 ,
204
+ 'n_clicks_timestamp' : 1615103040528 },
205
+ '{"_id":"inp-2","_type":"btn4"}' : {'n_clicks' : 15 ,
206
+ 'n_clicks_timestamp' : 1611733455354 },
207
+ '{"_id":"inp-2","_type":"btn5"}' : {'n_clicks' : 20 ,
208
+ 'n_clicks_timestamp' : 1611733455754 }}
201
209
202
210
assert DashApp .objects .get (instance_name = "Some name" ).current_state () == final_state
203
211
0 commit comments