Skip to content

Fix totalconnect AttributeError introduced in 0.107#33079

Merged
balloob merged 5 commits intohome-assistant:devfrom
austinmroczek:32952
Mar 21, 2020
Merged

Fix totalconnect AttributeError introduced in 0.107#33079
balloob merged 5 commits intohome-assistant:devfrom
austinmroczek:32952

Conversation

@austinmroczek
Copy link
Copy Markdown
Contributor

Proposed change

Updates totalconnect's alarm_control_panel code to account for changes in total-connect-client 0.54.1.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [n/a] Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@frenck
Copy link
Copy Markdown
Member

frenck commented Mar 21, 2020

There are unrelated commits in this PR.

Could you please clean it up? Thanks! 👍

Comment thread homeassistant/components/totalconnect/alarm_control_panel.py Outdated
mock_client.is_triggered_fire.return_value = True
mock_client.is_triggered_gas.return_value = True

alarm = TotalConnectAlarm("test", "123456", mock_client)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not instantiate the entity directly. Instead set up the component and platform let it add an entity and then assert the state of the entity via the state machine. Make sure to patch the library appropriately to avoid I/O.

See eg:

async def test_arm_home_with_pending(hass):
"""Test arm home method."""
assert await async_setup_component(
hass,
alarm_control_panel.DOMAIN,
{
"alarm_control_panel": {
"platform": "manual",
"name": "test",
"code": CODE,
"pending_time": 1,
"disarm_after_trigger": False,
}
},
)
entity_id = "alarm_control_panel.test"
assert STATE_ALARM_DISARMED == hass.states.get(entity_id).state
await common.async_alarm_arm_home(hass, CODE, entity_id)
assert STATE_ALARM_PENDING == hass.states.get(entity_id).state
state = hass.states.get(entity_id)
assert state.attributes["post_pending_state"] == STATE_ALARM_ARMED_HOME
future = dt_util.utcnow() + timedelta(seconds=1)
with patch(
("homeassistant.components.manual.alarm_control_panel.dt_util.utcnow"),
return_value=future,
):
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert state.state == STATE_ALARM_ARMED_HOME

@balloob
Copy link
Copy Markdown
Member

balloob commented Mar 21, 2020

Please do not push revert commits but start a new branch.

@balloob balloob added this to the 0.107.5 milestone Mar 21, 2020
@austinmroczek
Copy link
Copy Markdown
Contributor Author

Since this is a bugfix for something broken right now, if it's o.k. I will work to improve the tests in a separate PR.

@MartinHjelmare
Copy link
Copy Markdown
Member

Yes, that's fine.

Please make sure the build passes, then we can merge.

@balloob balloob merged commit ba25587 into home-assistant:dev Mar 21, 2020
balloob pushed a commit that referenced this pull request Mar 21, 2020
* Fit git

* Remove period from loggging message

* Remove tests for now

* Add const.py

* Fix lint error
@balloob balloob mentioned this pull request Mar 21, 2020
balloob pushed a commit that referenced this pull request Mar 21, 2020
* Fit git

* Remove period from loggging message

* Remove tests for now

* Add const.py

* Fix lint error
@lock lock Bot locked and limited conversation to collaborators Mar 27, 2020
@austinmroczek austinmroczek deleted the 32952 branch April 26, 2020 21:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'TotalConnectClient' object has no attribute 'DISARMED' in 0.107.0

5 participants