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

Removed hardcoded credentials in test_discoverable #157

Merged
merged 3 commits into from
Dec 19, 2023
Merged
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
20 changes: 5 additions & 15 deletions tests/test_discoverable.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@

@pytest.fixture
def discoverable() -> Discoverable[EntityInfo]:
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
mqtt_settings = Settings.MQTT(host="localhost")
sensor_info = EntityInfo(name="test", component="binary_sensor")
settings = Settings(mqtt=mqtt_settings, entity=sensor_info)
return Discoverable[EntityInfo](settings)
Expand All @@ -46,9 +44,7 @@ def discoverable() -> Discoverable[EntityInfo]:
@pytest.fixture
def discoverable_availability() -> Discoverable[EntityInfo]:
"""Return an instance of Discoverable configured with `manual_availability`"""
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
mqtt_settings = Settings.MQTT(host="localhost")
sensor_info = EntityInfo(name="test", component="binary_sensor")
settings = Settings(
mqtt=mqtt_settings, entity=sensor_info, manual_availability=True
Expand Down Expand Up @@ -204,19 +200,15 @@ def test_device_with_unique_id():


def test_name_with_space():
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
mqtt_settings = Settings.MQTT(host="localhost")
sensor_info = EntityInfo(name="Name with space", component="binary_sensor")
settings = Settings(mqtt=mqtt_settings, entity=sensor_info)
d = Discoverable[EntityInfo](settings)
d.write_config()


def test_custom_object_id():
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
mqtt_settings = Settings.MQTT(host="localhost")
sensor_info = EntityInfo(
name="Test name", component="binary_sensor", object_id="custom object id"
)
Expand Down Expand Up @@ -301,9 +293,7 @@ def test_disconnect_client(mocker: MockerFixture):
mocked_client = mocker.patch("paho.mqtt.client.Client")
mock_instance = mocked_client.return_value
mock_instance.connect.return_value = MQTT_ERR_SUCCESS
mqtt_settings = Settings.MQTT(
host="localhost", username="admin", password="password"
)
mqtt_settings = Settings.MQTT(host="localhost")
sensor_info = EntityInfo(name="test", component="binary_sensor")
settings = Settings(mqtt=mqtt_settings, entity=sensor_info)

Expand Down