Support multiple attachments in signal messenger integration#31141
Conversation
| filename = None | ||
| if data is not None and ATTR_FILENAME in data: | ||
| filename = data[ATTR_FILENAME] | ||
| filenames = None |
There was a problem hiding this comment.
I would prefer that we avoid the breaking change unnecessarily here.
This could be done by allowing both the attribute filename as well as the attribute filenames to be provided and then internally adding the filename to the list of filenames.
There was a problem hiding this comment.
Sounds good to me 👍 I'll adapt the PR, thanks!
Should the attachment option also be mentioned in the documentation then, or would you see that primarily as a way to stay backwards compatible and as something that's not worth mentioning in the documentation?
There was a problem hiding this comment.
I would mark it as deprecated and log a warning that it's deprecated and will be removed in version x.y.z (pick a version that's like 3 versions out).
If you are using vol to validate the schema of the service call, we have the deprecated validation helper in config_validation
Alternatively we could keep using attachment as the key and accept both a singular string or a list of strings.
There was a problem hiding this comment.
Thanks a lot for your suggestions, very much appreciated!
I've updated the PR, please let me know if there's anything else that needs to be changed.
(I've also removed the Breaking changes section from the PR description)
* stay backwards compatible by both allowing the "attachment" and the "attachments" attribute.
* stay backwards compatible by both allowing the "attachment" and the "attachments" attribute.
* added deprecation warning for 'attachment' attribute
rohankapoorcom
left a comment
There was a problem hiding this comment.
Looks good, thanks for incorporating the feedback. The build is breaking though, that will need to be fixed before merge.
* use 'warning' instead of 'warn' when logging the warning message
Thanks a lot for your suggestions! I've updated the PR and everything except the |
The code coverage shows how much of the code is covered by tests. Therefore, you will have to add another test to hit the target for code coverage. Hope this helps! :) |
|
To clarify, codecov/patch is measuring the code coverage of the diff (exactly what changed in this pull request) |
|
I've added now 4 tests, but looks like the code coverage is still less than the check expects. Unfortunately, I do not have any experience with code coverage tools, so it's not really clear to me how they calculate the test coverage and what I need to do in order to hit the target. |
|
You have to remove your files from the coverage ignore file: needs to be removed from https://github.com/home-assistant/home-assistant/blob/dev/.coveragerc#L624 |
oh, damn...silly me...totally forgot about that. Many thanks! Hopefully the coverage will now improve 🤞 |
MartinHjelmare
left a comment
There was a problem hiding this comment.
Please address the comments in a new PR.
| assert hass.services.has_service(BASE_COMPONENT, "test") | ||
|
|
||
|
|
||
| class TestSignalMesssenger(unittest.TestCase): |
There was a problem hiding this comment.
New tests must be async standalone pytest test functions.
| recipients = ["+435565656565"] | ||
| number = "+43443434343" | ||
| client = SignalCliRestApi("http://127.0.0.1:8080", number) | ||
| self._signalmessenger = signalmessenger.SignalNotificationService( |
There was a problem hiding this comment.
We should never set up a notify service or create an entity directly. We should always use the core to set up the component and platform. That will make the tests robust.
| def test_send_message(self, mock): | ||
| """Test send message.""" | ||
| message = "Testing Signal Messenger platform :)" | ||
| mock.register_uri( |
There was a problem hiding this comment.
We don't need to test the library requests. We should patch the library and make sure that we are interfacing with the library correctly.
The library is responsible for testing that it makes the correct requests.
Breaking change
Proposed change
There was a feature request to support multiple attachments in a single Signal message. (bbernhard/signal-cli-rest-api#5) Unfortunately, this change wasn't possible without a breaking backwards compatibility (at least I haven't found a nice way to accomplish that; suggestions are welcome).
Type of change
Example entry for
configuration.yaml:see https://www.home-assistant.io/integrations/signal_messenger/
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale: