Skip to content

Rename smile to api #766

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

Merged
merged 1 commit into from
Jun 29, 2025
Merged

Rename smile to api #766

merged 1 commit into from
Jun 29, 2025

Conversation

bouwew
Copy link
Contributor

@bouwew bouwew commented Jun 29, 2025

to avoid smile.smile.xyz constructs

Summary by CodeRabbit

  • Refactor

    • Updated test code to consistently rename the variable referencing the connected device API from smile to api across all test files. No changes were made to test logic or behavior.
  • Tests

    • Adjusted parameter and variable names in test methods for improved clarity and consistency. No functional changes to the tests themselves.

to avoid smile.smile.xyz constructs
Copy link
Contributor

coderabbitai bot commented Jun 29, 2025

Walkthrough

All test files were updated to consistently rename the variable previously called smile (or variants like _smile) to api (or _api) wherever it referred to the connected device API instance. This renaming was applied throughout test functions, method parameters, and local variables, without altering any logic, control flow, or test behavior.

Changes

File(s) Change Summary
tests/test_adam.py, tests/test_anna.py Renamed all occurrences of smile to api in test functions and local variables.
tests/test_generic.py, tests/test_legacy_generic.py Renamed _smile to _api and smile to api in tuple unpacking and local variables.
tests/test_init.py Renamed smile to api throughout; updated function/method parameters and local variables accordingly.
tests/test_legacy_anna.py, tests/test_legacy_p1.py, tests/test_legacy_stretch.py Renamed smile to api in test methods, unpacking, assertions, and API calls.
tests/test_p1.py Renamed smile to api in test methods, unpacking, assertions, and API calls.

Sequence Diagram(s)

sequenceDiagram
    participant TestFunction
    participant API as api (formerly smile)
    participant Device

    TestFunction->>API: connect_wrapper() / connect_legacy_wrapper()
    API->>Device: Establish connection
    TestFunction->>API: Call device methods (e.g., device_test, tinker_thermostat)
    API->>Device: Perform requested action
    TestFunction->>API: close_connection()
    API->>Device: Close connection
Loading

Suggested reviewers

  • CoMPaTech

Poem

In the warren of tests, a change hops by,
Where "smile" once wandered, now "api" is nigh.
With whiskers of code and a twitch of delight,
We rabbits rename, keeping logic tight.
🐇 A hop, a skip, a variable anew—
Consistency blooms in the fields we review!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.7)
tests/test_adam.py
tests/test_anna.py
tests/test_generic.py
  • 6 others
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch api-smile

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copy link

codecov bot commented Jun 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (52f28a5) to head (8700fbc).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #766   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         3382      3382           
=========================================
  Hits          3382      3382           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bouwew bouwew marked this pull request as ready for review June 29, 2025 09:52
@bouwew bouwew requested a review from a team as a code owner June 29, 2025 09:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/test_init.py (1)

480-492: Parameter rename propagated, but default value remains odd

device_test(self, api=pw_smile.Smile, …) still defaults to the class rather than an instance, which is unchanged behaviour but a little surprising. Not introduced by this PR, so no action required now, just flagging for future cleanup.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52f28a5 and 8700fbc.

📒 Files selected for processing (9)
  • tests/test_adam.py (12 hunks)
  • tests/test_anna.py (24 hunks)
  • tests/test_generic.py (2 hunks)
  • tests/test_init.py (28 hunks)
  • tests/test_legacy_anna.py (2 hunks)
  • tests/test_legacy_generic.py (1 hunks)
  • tests/test_legacy_p1.py (3 hunks)
  • tests/test_legacy_stretch.py (4 hunks)
  • tests/test_p1.py (4 hunks)
🧰 Additional context used
🧠 Learnings (8)
tests/test_legacy_generic.py (2)
Learnt from: bouwew
PR: plugwise/python-plugwise#627
File: tests/test_init.py:340-340
Timestamp: 2024-10-08T15:35:25.180Z
Learning: In `tests/test_init.py`, within the `connect` method, the `stretch` parameter is not relevant.
Learnt from: bouwew
PR: plugwise/python-plugwise#627
File: tests/test_init.py:340-340
Timestamp: 2024-09-25T09:00:19.434Z
Learning: In `tests/test_init.py`, within the `connect` method, the `stretch` parameter is not relevant.
tests/test_legacy_p1.py (2)
Learnt from: bouwew
PR: plugwise/python-plugwise#678
File: plugwise/legacy/helper.py:69-69
Timestamp: 2024-12-22T09:37:24.648Z
Learning: The code in plugwise/legacy/helper.py is fully separated from plugwise/helper.py. The user indicates that the problem signaled about the mismatch of the variable name (_home_location vs _home_loc_id) does not actually apply.
Learnt from: CoMPaTech
PR: plugwise/python-plugwise#698
File: fixtures/m_adam_multiple_devices_per_zone/data.json:21-21
Timestamp: 2025-01-29T19:14:31.257Z
Learning: MAC addresses in test fixtures of the python-plugwise repository are mock addresses and do not represent real device information.
tests/test_adam.py (1)
Learnt from: CoMPaTech
PR: plugwise/python-plugwise#698
File: fixtures/m_adam_multiple_devices_per_zone/data.json:21-21
Timestamp: 2025-01-29T19:14:31.257Z
Learning: MAC addresses in test fixtures of the python-plugwise repository are mock addresses and do not represent real device information.
tests/test_legacy_anna.py (1)
Learnt from: bouwew
PR: plugwise/python-plugwise#678
File: plugwise/legacy/helper.py:69-69
Timestamp: 2024-12-22T09:37:24.648Z
Learning: The code in plugwise/legacy/helper.py is fully separated from plugwise/helper.py. The user indicates that the problem signaled about the mismatch of the variable name (_home_location vs _home_loc_id) does not actually apply.
tests/test_legacy_stretch.py (3)
Learnt from: bouwew
PR: plugwise/python-plugwise#627
File: tests/test_init.py:340-340
Timestamp: 2024-09-25T09:00:19.434Z
Learning: In `tests/test_init.py`, within the `connect` method, the `stretch` parameter is not relevant.
Learnt from: bouwew
PR: plugwise/python-plugwise#627
File: tests/test_init.py:340-340
Timestamp: 2024-10-08T15:35:25.180Z
Learning: In `tests/test_init.py`, within the `connect` method, the `stretch` parameter is not relevant.
Learnt from: bouwew
PR: plugwise/python-plugwise#678
File: plugwise/legacy/helper.py:69-69
Timestamp: 2024-12-22T09:37:24.648Z
Learning: The code in plugwise/legacy/helper.py is fully separated from plugwise/helper.py. The user indicates that the problem signaled about the mismatch of the variable name (_home_location vs _home_loc_id) does not actually apply.
tests/test_p1.py (1)
Learnt from: CoMPaTech
PR: plugwise/python-plugwise#698
File: fixtures/m_adam_multiple_devices_per_zone/data.json:21-21
Timestamp: 2025-01-29T19:14:31.257Z
Learning: MAC addresses in test fixtures of the python-plugwise repository are mock addresses and do not represent real device information.
tests/test_anna.py (3)
Learnt from: bouwew
PR: plugwise/python-plugwise#678
File: plugwise/legacy/helper.py:69-69
Timestamp: 2024-12-22T09:37:24.648Z
Learning: The code in plugwise/legacy/helper.py is fully separated from plugwise/helper.py. The user indicates that the problem signaled about the mismatch of the variable name (_home_location vs _home_loc_id) does not actually apply.
Learnt from: bouwew
PR: plugwise/python-plugwise#671
File: plugwise/legacy/data.py:97-106
Timestamp: 2024-12-13T11:26:00.100Z
Learning: In `plugwise/legacy/data.py`, the legacy thermostat does not support cooling, so handling of the cooling state is unnecessary in this code.
Learnt from: CoMPaTech
PR: plugwise/python-plugwise#698
File: fixtures/m_adam_multiple_devices_per_zone/data.json:21-21
Timestamp: 2025-01-29T19:14:31.257Z
Learning: MAC addresses in test fixtures of the python-plugwise repository are mock addresses and do not represent real device information.
tests/test_init.py (2)
Learnt from: bouwew
PR: plugwise/python-plugwise#678
File: plugwise/legacy/helper.py:69-69
Timestamp: 2024-12-22T09:37:24.648Z
Learning: The code in plugwise/legacy/helper.py is fully separated from plugwise/helper.py. The user indicates that the problem signaled about the mismatch of the variable name (_home_location vs _home_loc_id) does not actually apply.
Learnt from: bouwew
PR: plugwise/python-plugwise#671
File: plugwise/legacy/data.py:97-106
Timestamp: 2024-12-13T11:26:00.100Z
Learning: In `plugwise/legacy/data.py`, the legacy thermostat does not support cooling, so handling of the cooling state is unnecessary in this code.
🧬 Code Graph Analysis (5)
tests/test_legacy_generic.py (1)
tests/test_init.py (1)
  • connect_legacy_wrapper (403-448)
tests/test_generic.py (1)
tests/test_init.py (1)
  • connect_wrapper (366-401)
tests/test_legacy_anna.py (2)
tests/test_init.py (6)
  • connect_legacy_wrapper (403-448)
  • validate_test_basics (988-1010)
  • device_test (480-601)
  • tinker_legacy_thermostat (828-845)
  • disconnect (453-456)
  • tinker_legacy_thermostat_schedule (765-789)
plugwise/smilecomm.py (1)
  • close_connection (148-150)
tests/test_legacy_stretch.py (2)
tests/test_init.py (4)
  • connect_legacy_wrapper (403-448)
  • validate_test_basics (988-1010)
  • device_test (480-601)
  • tinker_switch (620-648)
plugwise/smilecomm.py (1)
  • close_connection (148-150)
tests/test_p1.py (5)
tests/test_init.py (3)
  • connect_wrapper (366-401)
  • validate_test_basics (988-1010)
  • device_test (480-601)
plugwise/__init__.py (1)
  • gateway_id (96-98)
plugwise/helper.py (1)
  • gateway_id (90-92)
plugwise/exceptions.py (1)
  • ResponseError (36-37)
plugwise/smilecomm.py (1)
  • close_connection (148-150)
🪛 Gitleaks (8.26.0)
tests/test_adam.py

30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


80-80: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

tests/test_legacy_stretch.py

74-74: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


78-78: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (12)
tests/test_legacy_generic.py (1)

16-16: LGTM! Variable renaming improves clarity.

The renaming of _smile to _api is consistent with the PR objective to avoid "smile.smile.xyz" constructs and makes the variable purpose clearer.

tests/test_generic.py (2)

20-20: LGTM! Consistent variable renaming.

The renaming of _smile to _api maintains consistency with the broader refactoring effort and improves code clarity.


62-62: LGTM! Variable naming consistency maintained.

The renaming of smile to api is consistent with the other changes in this file and across the codebase.

tests/test_adam.py (1)

25-181: LGTM! Comprehensive and consistent variable renaming.

The systematic renaming of smile to api throughout all test methods is well-executed and consistent. This change successfully achieves the PR objective of avoiding "smile.smile.xyz" constructs while preserving all test logic and functionality.

Note: The static analysis hints about "Generic API Key" are false positives - they're detecting variable names containing "api" rather than actual API keys.

tests/test_legacy_anna.py (1)

21-76: LGTM! Consistent variable renaming across test methods.

The renaming of smile to api is comprehensive and consistent across both test methods. All references have been properly updated while preserving the original test logic and functionality.

tests/test_legacy_p1.py (1)

19-67: LGTM! Final consistent variable renaming completes the refactoring.

The renaming of smile to api across both test methods is comprehensive and consistent, completing the systematic refactoring effort across the test suite. All references have been properly updated while maintaining the original test functionality.

tests/test_legacy_stretch.py (2)

19-28: Rename looks good – no functional impact detected

Tuple unpacking and all subsequent references were updated from smileapi. The change is self-contained, keeps the order (server, api, client) consistent with the value returned by connect_legacy_wrapper, and doesn’t touch test logic or assertions.


73-86: Static-analysis “API-key” warnings are false positives

The long hexadecimal strings (2587a7fcdd7e…) are fixture device-ids, not credentials. No remediation needed; you can safely ignore the Gitleaks generic-API-key warnings.

tests/test_p1.py (1)

18-26: Consistent variable rename

server, api, client unpacking and every downstream use of api were updated correctly; test behaviour remains unchanged.

tests/test_anna.py (2)

21-33: api rename applied correctly

All occurrences in the v4 test path were switched to api, including assertions and calls to helper functions. No missed references detected.


667-678: Confirmed: no remaining smile= keyword arguments—rename is safe

I’ve searched the entire codebase for smile= and found no occurrences. The api.smile.name access inside tinker_thermostat_temp still refers to the correct domain object, so no changes are needed here.

tests/test_init.py (1)

323-338: Constructor invocation updated – ✅

Both the “no websession” negative test and the real constructor call now use api consistently. Return tuple at line 355 aligns with callers (server, api, client).

Copy link
Member

@CoMPaTech CoMPaTech left a comment

Choose a reason for hiding this comment

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

I doubt it needs a full review (with a lot of renames) :)

@bouwew
Copy link
Contributor Author

bouwew commented Jun 29, 2025

A bit of "monniken-werk", but with find-replace well doable :)
And with Gitkraken I can see that I've modified all test-files.

@CoMPaTech
Copy link
Member

A bit of "monniken-werk", but with find-replace well doable :) And with Gitkraken I can see that I've modified all test-files.

I know most IDEs can just replace 'all occurances' intelligently but I'm always a bit reluctant with them :) Great work, @bouwew

@bouwew bouwew merged commit 611fcba into main Jun 29, 2025
17 checks passed
@bouwew bouwew deleted the api-smile branch June 29, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants