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

binary_sensor.workday: fix handling of states vs provinces #7162

Merged
merged 6 commits into from
Apr 30, 2017

Conversation

drkp
Copy link
Contributor

@drkp drkp commented Apr 18, 2017

Description:

The holidays module treats states and provinces differently, so specifying a US state as a province does not work correctly. #7017 is incomplete; it prevents an error on startup when a state is specified, but does not load the correct holidays for that state. This is a fix.

Also added test cases.

Related issue (if applicable): fixes #7015

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link

@drkp, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff and @BastianPoe to be potential reviewers.

@@ -66,15 +66,19 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
obj_holidays = getattr(holidays, country)(years=year)

if province:
if province not in obj_holidays.PROVINCES and \
province not in obj_holidays.STATES:
year = datetime.datetime.now().year
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a duplicate. See Line 65.

@BastianPoe
Copy link
Contributor

Apart from the change request by @fabaff, the rest seems to be fine!

@drkp
Copy link
Contributor Author

drkp commented Apr 18, 2017

Good catch, fixed. Thanks!

fabaff
fabaff previously approved these changes Apr 19, 2017
@fabaff fabaff closed this Apr 19, 2017
@fabaff fabaff reopened this Apr 19, 2017
@BastianPoe
Copy link
Contributor

This should further increase the test coverage (that was something I overlooked when originally creating the tests):
0001-Repair-unit-test-to-improve-coverage.patch.zip

Could you please create a test for also covering the remaining two (so far uncovered) lines (see https://coveralls.io/builds/11143076/source?filename=homeassistant%2Fcomponents%2Fbinary_sensor%2Fworkday.py#L78 and https://coveralls.io/builds/11143076/source?filename=homeassistant%2Fcomponents%2Fbinary_sensor%2Fworkday.py#L80)? Thanks!

@fabaff fabaff dismissed their stale review April 28, 2017 22:35

Missing tests.

@drkp
Copy link
Contributor Author

drkp commented Apr 29, 2017

100% coverage on this component now.

@balloob
Copy link
Member

balloob commented Apr 30, 2017

Thanks! 🐬

@balloob balloob merged commit 7ff1ded into home-assistant:dev Apr 30, 2017
@balloob balloob mentioned this pull request May 5, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Aug 12, 2017
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.

binary_sensor.workday doesn't support US states
7 participants