forked from plotly/dash-core-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_date_picker_range.py
111 lines (89 loc) · 3.06 KB
/
test_date_picker_range.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from datetime import datetime
import dash
import dash_html_components as html
import dash_core_components as dcc
def test_dtpr001_initial_month_provided(dash_dcc):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.DatePickerRange(
id="dps-initial-month",
min_date_allowed=datetime(2010, 1, 1),
max_date_allowed=datetime(2099, 12, 31),
initial_visible_month=datetime(2019, 10, 28),
)
]
)
dash_dcc.start_server(app)
date_picker_start = dash_dcc.find_element(
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]'
)
date_picker_start.click()
dash_dcc.wait_for_text_to_equal(
"#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong",
"October 2019",
1,
)
def test_dtpr002_no_initial_month_min_date(dash_dcc):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.DatePickerRange(
id="dps-initial-month",
min_date_allowed=datetime(2010, 1, 1),
max_date_allowed=datetime(2099, 12, 31),
)
]
)
dash_dcc.start_server(app)
date_picker_start = dash_dcc.find_element(
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]'
)
date_picker_start.click()
dash_dcc.wait_for_text_to_equal(
"#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong",
"January 2010",
)
def test_dtpr003_no_initial_month_no_min_date_start_date(dash_dcc):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.DatePickerRange(
id="dps-initial-month",
start_date=datetime(2019, 8, 13),
max_date_allowed=datetime(2099, 12, 31),
)
]
)
dash_dcc.start_server(app)
date_picker_start = dash_dcc.find_element(
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]'
)
date_picker_start.click()
dash_dcc.wait_for_text_to_equal(
"#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong",
"August 2019",
)
def test_dtpr004_max_and_min_dates_are_clickable(dash_dcc):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.DatePickerRange(
id="dps-initial-month",
start_date=datetime(2021, 1, 11),
end_date=datetime(2021, 1, 19),
max_date_allowed=datetime(2021, 1, 20),
min_date_allowed=datetime(2021, 1, 10),
)
]
)
dash_dcc.start_server(app)
dash_dcc.select_date_range("dps-initial-month", (10, 20))
dash_dcc.wait_for_text_to_equal(
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]',
"01/10/2021",
)
dash_dcc.wait_for_text_to_equal(
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="End Date"]',
"01/20/2021",
)