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

Return history for entities in the order they were requested #25560

Merged
merged 3 commits into from
Jul 31, 2019
Merged

Return history for entities in the order they were requested #25560

merged 3 commits into from
Jul 31, 2019

Conversation

thomasloven
Copy link
Contributor

@thomasloven thomasloven commented Jul 29, 2019

Description:

Return history data in order

Also see home-assistant/frontend#3436

Related issue (if applicable): fixes home-assistant/ui-schema#213

Pull request with documentation for home-assistant.io (if applicable): N/A

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

@thomasloven thomasloven requested a review from a team as a code owner July 29, 2019 15:18
@ghost
Copy link

ghost commented Jul 29, 2019

Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with a integration (history) you are listed as a codeowner for? Thanks!

This is a automatic comment generated by codeowners-mention to help ensure issues and pull requests are seen by the right people.

andrewsayre
andrewsayre previously approved these changes Jul 29, 2019
Copy link
Member

@andrewsayre andrewsayre left a comment

Choose a reason for hiding this comment

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

Can be merged once the lint issue is resolved!

@thomasloven
Copy link
Contributor Author

No. It's not working for entity_ids=None.
Shame on me. Will be fixed soon, though.

@andrewsayre
Copy link
Member

Do you think you could write a test case or 2 for the conditions if not already covered?

@thomasloven
Copy link
Contributor Author

Fixed.
The condition I broke was already in a test, but I added one for the order of the results.

Please take an extra look on that one. I'm not comfortable with writing tests yet...

Copy link
Member

@andrewsayre andrewsayre left a comment

Choose a reason for hiding this comment

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

Looks good!

tests/testing_config/.ps4-games.json Outdated Show resolved Hide resolved
@thomasloven
Copy link
Contributor Author

thomasloven commented Jul 29, 2019

Failing test is for Python 3.5, which is to be expected.

Edit: For clarification, everything works the same way as it always did with python 3.5 rather than in the new way, so the new test fails.

Is there an option to ignore tests for certain python versions?

@cgtobi
Copy link
Contributor

cgtobi commented Jul 30, 2019

@thomasloven you can use pytest.mark.skipif to skip if lower that 3.6.

@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6 or higher")

@thomasloven
Copy link
Contributor Author

Thanks. That gave me what I needed to find the unittest equivalent.

@pvizeli
Copy link
Member

pvizeli commented Jul 30, 2019

Ignore is no options because it's the current main version. End of the week we remove python3.5 and we don't block this PR after that.

@thomasloven
Copy link
Contributor Author

Good point. Reverting

@balloob
Copy link
Member

balloob commented Jul 30, 2019

Py36 PR #25582

@@ -211,6 +212,9 @@ def states_to_json(
axis correctly.
"""
result = defaultdict(list)
if isinstance(entity_ids, Iterable):
Copy link
Member

Choose a reason for hiding this comment

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

This is not a right check, a string is iterable too.

Copy link
Member

Choose a reason for hiding this comment

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

I guess it works because we don't pass a list. We should just guard against it being None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

*Gasp! Stack overflow lied to me!

Thanks for fixing.
Will entity_ids NEVER be a single entity_id in a string?

Copy link
Member

Choose a reason for hiding this comment

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

based on the code, no.

@balloob balloob merged commit 671cb0d into home-assistant:dev Jul 31, 2019
@lock lock bot locked and limited conversation to collaborators Aug 1, 2019
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.

Order of entities in History-graph (Lovelace)
6 participants