Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit 5823cef

Browse files
committed
update test
1 parent f2c515f commit 5823cef

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

tests/test_integration.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,50 +88,70 @@ def update_output(n_clicks):
8888

8989
def test_click_prev(self):
9090
call_count = Value('i', 0)
91+
timestamp_1 = Value('d', -5)
92+
timestamp_2 = Value('d', -5)
9193

9294
app = dash.Dash()
9395
app.layout = html.Div([
9496
html.Div(id='container'),
95-
html.Button('Click', id='button-1', n_clicks=0, n_clicks_previous=0),
96-
html.Button('Click', id='button-2', n_clicks=0, n_clicks_previous=0)
97+
html.Button('Click', id='button-1', n_clicks=0, n_clicks_timestamp=-1),
98+
html.Button('Click', id='button-2', n_clicks=0, n_clicks_timestamp=-1)
9799
])
98100

99101
@app.callback(
100102
Output('container', 'children'),
101103
[Input('button-1', 'n_clicks'),
102-
Input('button-1', 'n_clicks_previous'),
104+
Input('button-1', 'n_clicks_timestamp'),
103105
Input('button-2', 'n_clicks'),
104-
Input('button-2', 'n_clicks_previous')])
106+
Input('button-2', 'n_clicks_timestamp')])
105107
def update_output(*args):
108+
print(args)
106109
call_count.value += 1
107-
return '{}, {}, {}, {}'.format(*args)
110+
timestamp_1.value = args[1]
111+
timestamp_2.value = args[3]
112+
return '{}, {}'.format(args[0], args[2])
108113

109114
self.startServer(app)
110115

111116
self.wait_for_element_by_css_selector('#container')
112117
time.sleep(2)
113-
self.wait_for_text_to_equal(
114-
'#container', '0, 0, 0, 0')
118+
self.wait_for_text_to_equal('#container', '0, 0')
119+
self.assertEqual(timestamp_1.value, -1)
120+
self.assertEqual(timestamp_2.value, -1)
115121
self.assertEqual(call_count.value, 1)
116122
self.snapshot('button initialization 1')
117123

118124
self.driver.find_element_by_css_selector('#button-1').click()
119125
time.sleep(2)
120-
self.wait_for_text_to_equal(
121-
'#container', '0, 1, 0, 0')
126+
self.wait_for_text_to_equal('#container', '1, 0')
127+
print(timestamp_1.value)
128+
print((time.time() - (24 * 60 * 60)) * 1000)
129+
self.assertTrue(
130+
timestamp_1.value >
131+
((time.time() - (24 * 60 * 60)) * 1000))
132+
self.assertEqual(timestamp_2.value, -1)
122133
self.assertEqual(call_count.value, 2)
123134
self.snapshot('button-1 click')
135+
prev_timestamp_1 = timestamp_1.value
124136

125137
self.driver.find_element_by_css_selector('#button-2').click()
126138
time.sleep(2)
127-
self.wait_for_text_to_equal(
128-
'#container', '1, 1, 0, 1')
139+
self.wait_for_text_to_equal('#container', '1, 1')
140+
self.assertEqual(timestamp_1.value, prev_timestamp_1)
141+
self.assertTrue(
142+
timestamp_2.value >
143+
((time.time() - 24 * 60 * 60) * 1000))
129144
self.assertEqual(call_count.value, 3)
130145
self.snapshot('button-2 click')
146+
prev_timestamp_2 = timestamp_2.value
131147

132148
self.driver.find_element_by_css_selector('#button-2').click()
133149
time.sleep(2)
134-
self.wait_for_text_to_equal(
135-
'#container', '1, 1, 1, 2')
150+
self.wait_for_text_to_equal('#container', '1, 2')
151+
self.assertEqual(timestamp_1.value, prev_timestamp_1)
152+
self.assertTrue(
153+
timestamp_2.value >
154+
prev_timestamp_2)
155+
self.assertTrue(timestamp_2.value > timestamp_1.value)
136156
self.assertEqual(call_count.value, 4)
137157
self.snapshot('button-2 click again')

0 commit comments

Comments
 (0)