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

Improved types for generated service arguments #1149

Merged
merged 2 commits into from
Aug 18, 2024

Conversation

FrankBakkerNl
Copy link
Contributor

Improved the parameter types for some generated service arguments. specifically:
date => DateOnly
time => TimeOnly
datetime => DateTime
rgb_color => IReadOnlyCollection,
number without 'step' is now double instead of long

This will allow for eg:
Light.Attic.TurnOn(transition: 0.5, rgbColor: [255,128,10]);

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • 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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • The code compiles without warnings (code quality check)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration are added/changed:

@helto4real helto4real added the pr: breaking change Set it PR is breaking label Aug 17, 2024
Copy link

codecov bot commented Aug 17, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82%. Comparing base (b1f7fea) to head (a1fcaf6).
Report is 1 commits behind head on main.

Files Patch % Lines
...Data/ServicesMetaData/HassServiceArgumentMapper.cs 66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@         Coverage Diff          @@
##           main   #1149   +/-   ##
====================================
  Coverage    82%     82%           
====================================
  Files       190     190           
  Lines      3779    3781    +2     
  Branches    425     425           
====================================
+ Hits       3107    3115    +8     
+ Misses      507     499    -8     
- Partials    165     167    +2     
Flag Coverage Δ
unittests 82% <66%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -46,7 +46,7 @@ public void TestSomeBasicServicesCanBeParsed()
[Fact]
public void TestServicesWithAdvancedFieldsCanBeParsed()
{
var sample = File.ReadAllText(@"CodeGenerator/ServiceMetaDataSamples/Lights.json");
var sample = File.ReadAllText(@"CodeGenerator/ServiceMetaDataSamples/light.json");
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a raw string literal be a better way to store the json string? Then you don't have to do any file IO in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For these very long ones it seems to me it clutters the test to put them inline. That is arbitrary of course

Copy link
Contributor

Choose a reason for hiding this comment

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

You could put them in a separate class as constants (especially when these are used in multiple tests)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is fine keep them in a file, the tests are not really taking that long.

Copy link
Collaborator

@helto4real helto4real 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 to me, I think this breaking change is manageable and adds enough value

@@ -46,7 +46,7 @@ public void TestSomeBasicServicesCanBeParsed()
[Fact]
public void TestServicesWithAdvancedFieldsCanBeParsed()
{
var sample = File.ReadAllText(@"CodeGenerator/ServiceMetaDataSamples/Lights.json");
var sample = File.ReadAllText(@"CodeGenerator/ServiceMetaDataSamples/light.json");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is fine keep them in a file, the tests are not really taking that long.

@helto4real helto4real merged commit 91b7295 into net-daemon:main Aug 18, 2024
7 of 9 checks passed
helto4real pushed a commit that referenced this pull request Feb 4, 2025
* Improved types for generated service arguments

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants