Skip to content

Commit a1918b9

Browse files
committed
Add and update DateRangePicker integration tests
Updated the 'basic' DateRangePicker test and golden image, and added a new 'properties1' test with corresponding screenshot. The new test covers various DateRangePicker properties to improve test coverage and reliability.
1 parent 8e75d43 commit a1918b9

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

3.06 KB
Loading
69.2 KB
Loading

sdk/python/packages/flet/integration_tests/controls/test_date_range_picker.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
import datetime
22

33
import pytest
4+
import pytest_asyncio
45

56
import flet as ft
67
import flet.testing as ftt
78

89

9-
@pytest.mark.asyncio(loop_scope="module")
10+
# Create a new flet_app instance for each test method
11+
@pytest_asyncio.fixture(scope="function", autouse=True)
12+
def flet_app(flet_app_function):
13+
return flet_app_function
14+
15+
16+
@pytest.mark.asyncio(loop_scope="function")
1017
async def test_basic(flet_app: ftt.FletTestApp, request):
1118
dp = ft.DateRangePicker(
1219
start_value=datetime.datetime(year=2000, month=10, day=1),
1320
end_value=datetime.datetime(year=2000, month=10, day=15),
21+
first_date=datetime.datetime(year=2000, month=10, day=1),
22+
last_date=datetime.datetime(year=2000, month=11, day=15),
23+
current_date=datetime.datetime(year=2000, month=10, day=16),
1424
)
1525
flet_app.page.enable_screenshots = True
1626
flet_app.page.window.width = 400
@@ -25,3 +35,44 @@ async def test_basic(flet_app: ftt.FletTestApp, request):
2535
pixel_ratio=flet_app.screenshots_pixel_ratio
2636
),
2737
)
38+
39+
40+
@pytest.mark.asyncio(loop_scope="function")
41+
async def test_properties1(flet_app: ftt.FletTestApp, request):
42+
dp = ft.DateRangePicker(
43+
start_value=datetime.datetime(year=2000, month=10, day=7),
44+
end_value=datetime.datetime(year=2000, month=10, day=15),
45+
first_date=datetime.datetime(year=2000, month=10, day=1),
46+
last_date=datetime.datetime(year=2000, month=11, day=15),
47+
current_date=datetime.datetime(year=2000, month=10, day=16),
48+
switch_to_calendar_icon=ft.Icons.BABY_CHANGING_STATION,
49+
switch_to_input_icon=ft.Icons.ACCESS_ALARM,
50+
save_text="Custom save text",
51+
error_invalid_range_text="Invalid range custom text",
52+
help_text="Custom help text",
53+
cancel_text="Custom cancel text",
54+
confirm_text="Custom confirm text",
55+
error_format_text="Custom error format text",
56+
error_invalid_text="Custom error invalid text",
57+
field_end_hint_text="Custom end hint text",
58+
field_start_hint_text="Custom start hint text",
59+
field_end_label_text="Custom end label text",
60+
field_start_label_text="Custom start label text",
61+
modal=False,
62+
barrier_color=ft.Colors.RED,
63+
keyboard_type=ft.KeyboardType.EMAIL,
64+
date_picker_entry_mode=ft.DatePickerEntryMode.CALENDAR,
65+
)
66+
flet_app.page.enable_screenshots = True
67+
flet_app.page.window.width = 400
68+
flet_app.page.window.height = 600
69+
flet_app.page.show_dialog(dp)
70+
flet_app.page.update()
71+
await flet_app.tester.pump_and_settle()
72+
73+
flet_app.assert_screenshot(
74+
"properties1",
75+
await flet_app.page.take_screenshot(
76+
pixel_ratio=flet_app.screenshots_pixel_ratio
77+
),
78+
)

0 commit comments

Comments
 (0)