Skip to content

Commit

Permalink
Merge pull request #157 from ha-enthus1ast/bugfix/gitleaks-fails
Browse files Browse the repository at this point in the history
Removed hardcoded credentials in test_discoverable
  • Loading branch information
unixorn authored Dec 19, 2023
2 parents 5357ba2 + 9135f97 commit 9507ce2
Showing 1 changed file with 5 additions and 15 deletions.
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

0 comments on commit 9507ce2

Please sign in to comment.