Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homeassistant 2023.10 #219

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx==7.2.6
furo==2023.9.10
urllib3==2.0.4
urllib3==2.0.7
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pytest-homeassistant-custom-component==0.13.53
pytest-homeassistant-custom-component==0.13.68
moonraker-api==2.0.5
aiohttp_cors==0.7.0
Pillow==10.0.0
pre-commit==3.4.0
Pillow==10.1.0
pre-commit==3.5.0
sphinx==7.2.6
colorlog==6.7.0
urllib3==2.0.4
urllib3==2.0.7
furo==2023.9.10
4 changes: 4 additions & 0 deletions tests/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def test_runout_filament_sensor_missing(hass, get_data, get_printer_object
)

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -39,6 +40,7 @@ async def test_runout_filament_sensor_missing(hass, get_data, get_printer_object

async def test_runout_filament_sensor(hass):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -48,6 +50,7 @@ async def test_runout_filament_sensor(hass):

async def test_multiple_runout_filament_sensor(hass):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -64,6 +67,7 @@ async def test_runout_filament_sensor_off(hass, get_data):
] = False

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down
3 changes: 3 additions & 0 deletions tests/test_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def bypass_connect_client_fixture():
)
async def test_buttons(hass, button, method):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -54,6 +55,7 @@ async def test_buttons(hass, button, method):

async def test_gcode_macro(hass):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -75,6 +77,7 @@ async def test_gcode_macro(hass):

async def test_disabled_buttons(hass):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down
12 changes: 12 additions & 0 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def test_camera_services(hass, caplog):
"""Test camera services"""

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -47,6 +48,7 @@ async def test_camera_services_full_path(hass, get_camera_info, caplog):
"snapshot_url"
] = "http://1.2.3.4/webcam/?action=2snapshot"
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -68,6 +70,7 @@ async def test_two_cameras_services(hass, get_camera_info):
)

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -87,6 +90,7 @@ async def test_two_cameras_same_name_services(hass, get_camera_info):
)

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -100,6 +104,7 @@ async def test_setup_thumbnail_camera(hass, get_data):
get_data["status"]["print_stats"]["filename"] = "CE3E3V2_picture_frame_holder.gcode"

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -117,6 +122,7 @@ async def test_thumbnail_camera_image(
get_data["status"]["print_stats"]["filename"] = "CE3E3V2_picture_frame_holder.gcode"

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -134,6 +140,7 @@ async def test_thumbnail_camera_from_img_to_none(hass):
"""Test thumbnail camera from img to none"""

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -146,6 +153,7 @@ async def test_thumbnail_no_thumbnail(hass, get_data):
get_data["status"]["print_stats"]["filename"] = ""

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -160,6 +168,7 @@ async def test_thumbnail_not_printing(hass, aioclient_mock, get_data):
get_data["status"]["print_stats"]["state"] = PRINTSTATES.STANDBY.value

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -183,6 +192,7 @@ async def test_thumbnail_no_thumbnail_after_update(
get_data["status"]["print_stats"]["filename"] = "CE3E3V2_picture_frame_holder.gcode"

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down Expand Up @@ -218,6 +228,7 @@ async def test_thumbnail_data_failing(
return_value={**get_data, **get_printer_info, **get_camera_info},
):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -235,6 +246,7 @@ async def test_thumbnail_on_subfolder(hass, get_data, aioclient_mock):
] = "subfolder/CE3E3V2_picture_frame_holder.gcode"

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down
5 changes: 5 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async def test_setup_unload_and_reload_entry(hass):
# Create a mock entry so we don't have to go through config flow

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)

assert await async_setup_entry(hass, config_entry)
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
Expand Down Expand Up @@ -56,6 +57,7 @@ async def test_setup_unload_and_reload_entry_with_name(hass):
config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG_WITH_NAME, entry_id="test"
)
config_entry.add_to_hass(hass)

assert await async_setup_entry(hass, config_entry)
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
Expand All @@ -80,6 +82,7 @@ async def test_async_send_data_exception(hass):
"""Test async_post_exception"""

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)

with patch(
Expand All @@ -101,6 +104,7 @@ async def test_setup_entry_exception(hass):
side_effect=Exception,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)

with pytest.raises(ConfigEntryNotReady):
assert await async_setup_entry(hass, config_entry)
Expand All @@ -121,6 +125,7 @@ async def test_failed_first_refresh(hass):
side_effect=load_data,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)

with pytest.raises(ConfigEntryNotReady):
assert await async_setup_entry(hass, config_entry)
1 change: 1 addition & 0 deletions tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def bypass_connect_client_fixture():
)
async def test_number_set_value(hass, number, get_default_api_response):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down
11 changes: 11 additions & 0 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def test_sensor_services_update(hass, get_data):
# Create a mock entry so we don't have to go through config flow

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down Expand Up @@ -112,6 +113,7 @@ async def test_sensors(
value,
):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down Expand Up @@ -141,6 +143,7 @@ async def test_sensors_not_printing(
):
get_data["status"]["print_stats"]["state"] = PRINTSTATES.STANDBY.value
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -152,6 +155,7 @@ async def test_opt_sensor_missing(hass, get_data, get_printer_objects_list):
get_printer_objects_list["objects"].remove("temperature_sensor mcu_temp")

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -161,6 +165,7 @@ async def test_opt_sensor_missing(hass, get_data, get_printer_objects_list):

async def test_eta(hass):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -176,6 +181,7 @@ async def test_eta(hass):

async def test_slicer_time_left(hass, get_data):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -195,6 +201,7 @@ async def test_eta_no_current_data(hass, get_data):
get_data["status"]["print_stats"]["print_duration"] = 0

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down Expand Up @@ -239,6 +246,7 @@ async def test_no_history_data(
},
):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -251,6 +259,7 @@ async def test_double_sensor_data(hass, get_data, get_printer_objects_list):
get_data["status"]["heater_fan controller_fan"] = {"speed": 0.1234}

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -274,6 +283,7 @@ async def test_no_fan_sensor(hass, get_data, get_printer_objects_list):
get_printer_objects_list["objects"].remove("fan")

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand All @@ -285,6 +295,7 @@ async def test_rounding_fan(hass, get_data):
get_data["status"]["fan"]["speed"] = 0.33333333333

config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down
2 changes: 2 additions & 0 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def bypass_connect_client_fixture():
)
async def test_switch_turn_on(hass, switch, switch_type, get_default_api_response):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down Expand Up @@ -74,6 +75,7 @@ async def test_switch_turn_on(hass, switch, switch_type, get_default_api_respons
)
async def test_switch_turn_off(hass, switch, switch_type, get_default_api_response):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down