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

398 Support optional "source" in /sensors/data [GET] #543

Merged
merged 23 commits into from Dec 2, 2022

Conversation

Flix6x
Copy link
Contributor

@Flix6x Flix6x commented Nov 28, 2022

Allow to filter requests for sensor data by data source. Users can find out relevant source ids from chart tooltips.

Also fixes the return message of /sensors/data [GET] and the replacement of NaN values with null values in the returned JSON.

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x self-assigned this Nov 28, 2022
@Flix6x Flix6x linked an issue Nov 28, 2022 that may be closed by this pull request
@coveralls
Copy link
Collaborator

coveralls commented Nov 28, 2022

Pull Request Test Coverage Report for Build 3600176789

  • 9 of 9 (100.0%) changed or added relevant lines in 4 files are covered.
  • 35 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.3%) to 65.23%

Files with Coverage Reduction New Missed Lines %
flexmeasures/data/services/scheduling.py 7 83.78%
flexmeasures/cli/data_add.py 28 31.53%
Totals Coverage Status
Change from base Build 3546393110: 0.3%
Covered Lines: 6616
Relevant Lines: 9519

💛 - Coveralls

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x marked this pull request as ready for review November 29, 2022 09:22
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
…rsion)

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

Great, also that you added a test for a crucial endpoint which wasn't covered before

One of my comments might make the test somewhat faster, I believe it should live in another module.

documentation/api/notation.rst Show resolved Hide resolved
flexmeasures/api/v3_0/tests/conftest.py Show resolved Hide resolved
flexmeasures/api/v3_0/tests/test_sensor_data_fresh_db.py Outdated Show resolved Hide resolved
@@ -50,3 +55,36 @@ def test_post_sensor_data(
assert len(beliefs) == expected_num_values
# check that values are scaled to the sensor unit correctly
assert pytest.approx(beliefs[0].event_value - expected_value) == 0


def test_get_sensor_data(
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this could be in the non-fresh part of testing, as the test itself mutates no data. And you added the data points in both versions.

Copy link
Contributor Author

@Flix6x Flix6x Dec 1, 2022

Choose a reason for hiding this comment

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

I first implemented it in the non-fresh db test module, but it did interfere there. And I found it was tricky. trickier than just adapting the assert statements that check the number of beliefs registered on the sensor shared by these tests. [That was actually only an issue in the fresh db test module]

Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x mentioned this pull request Dec 1, 2022
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x merged commit 9a05e9b into main Dec 2, 2022
@Flix6x Flix6x deleted the 398-support-optional-source-in-sensorsdata-get branch December 2, 2022 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support optional "source" in /sensors/data [GET]
3 participants