-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: update deprecated imports from ovos-utils #611
Conversation
WalkthroughThe changes in this pull request primarily involve modifications to import statements across various test files, specifically transitioning the source of Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning Rate limit exceeded@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 58 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (5)
test/backwards_compat/test_ocp.py (5)
Line range hint
8-13
: Remove commented out imports.These commented imports are no longer needed and should be removed for better code maintainability.
-# from ovos_plugin_common_play.ocp.mycroft_cps import MycroftAudioService -# from mycroft.configuration import Configuration
Line range hint
47-65
: Consider refactoring common test setup code.The
setUpClass
method and message handling setup is duplicated across all three test classes. Consider creating a base test class to reduce code duplication.class BaseOCPTest(unittest.TestCase): @classmethod @patch.object(Configuration, 'load_all_configs') def setUpClass(cls, mock) -> None: mock.return_value = BASE_CONF cls.bus = FakeBus() cls.bus.emitted_msgs = [] def get_msg(msg): msg = json.loads(msg) msg.pop("context") cls.bus.emitted_msgs.append(msg) cls.bus.on("message", get_msg) class TestOCPLoad(BaseOCPTest): # ... rest of the classAlso applies to: 89-107, 246-264
Line range hint
71-71
: Document skip reasons in test methods.Several tests are marked with
@pytest.mark.skip
without clear documentation explaining why they are skipped. Add comments explaining the skip reasons and any tracking issues.- @pytest.mark.skip + @pytest.mark.skip(reason="TODO: Document why this test is skipped and link to tracking issue") def test_native_ocp(self):Also applies to: 187-187, 359-359, 403-403, 447-447
Line range hint
359-402
: Consider using helper methods for message verification.The test contains multiple repeated message structure verifications. Consider creating helper methods to make the tests more readable and maintainable.
def assert_message_sent(self, expected_msg): """Helper method to verify message was sent on the bus""" self.assertIn(expected_msg, self.bus.emitted_msgs) def assert_play_messages(self, tracks, repeat=False, utterance=''): """Helper method to verify play-related messages""" expected = [ {'type': 'mycroft.audio.service.play', 'data': {'tracks': tracks, 'utterance': utterance, 'repeat': repeat}}, {'type': 'ovos.common_play.playlist.clear', 'data': {}} ] for msg in expected: self.assert_message_sent(msg)
Line range hint
246-456
: Consider adding error case test coverage.The test suite primarily covers happy path scenarios. Consider adding test cases for:
- Invalid track URIs
- Network errors during playback
- Invalid state transitions
- Malformed message handling
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (7)
test/backwards_compat/test_ocp.py
(1 hunks)test/end2end/minicroft.py
(1 hunks)test/integrationtests/common_query/test_continuous_dialog.py
(1 hunks)test/integrationtests/common_query/test_skill.py
(1 hunks)test/integrationtests/test_workshop.py
(1 hunks)test/unittests/test_skill_manager.py
(0 hunks)test/unittests/xformers.py
(1 hunks)
💤 Files with no reviewable changes (1)
- test/unittests/test_skill_manager.py
✅ Files skipped from review due to trivial changes (3)
- test/end2end/minicroft.py
- test/integrationtests/common_query/test_skill.py
- test/unittests/xformers.py
🔇 Additional comments (4)
test/integrationtests/common_query/test_continuous_dialog.py (2)
5-5
: LGTM! Good refactoring of test utilities.
The change appropriately moves test-specific message bus classes to a dedicated fakebus
module while maintaining backward compatibility through aliasing.
5-5
: Verify consistent import updates across test files.
Let's ensure this import change has been consistently applied across all test files using the message bus utilities.
✅ Verification successful
Import usage is consistent and correctly segregated between test types
The verification shows a clear and consistent pattern:
- Integration tests correctly use
FakeMessage
fromovos_utils.fakebus
- Unit tests and end-to-end tests appropriately use
Message
fromovos_bus_client
This segregation is intentional and correct:
- Integration tests need the fake message bus utilities
- Other test types require the actual message bus client
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining old imports and verify new import adoption
# Test 1: Check for any remaining old imports
echo "Checking for remaining old imports from messagebus..."
rg "from ovos_utils.messagebus import.*Message" "test/"
# Test 2: Verify adoption of new imports
echo "Verifying adoption of new fakebus imports..."
rg "from ovos_utils.fakebus import.*FakeMessage" "test/"
# Test 3: Check for potential missed Message imports
echo "Checking for other Message imports that might need updating..."
rg "import.*Message" "test/" --type py
Length of output: 2431
test/integrationtests/test_workshop.py (1)
7-7
: LGTM! Import updated from deprecated module.
The change correctly updates the imports from the deprecated messagebus
module to the new fakebus
module while maintaining backward compatibility through aliasing.
Let's verify the deprecation status and usage patterns:
✅ Verification successful
Import change verified and consistent across codebase
The verification confirms:
- No remaining deprecated imports from
ovos_utils.messagebus
- Consistent usage of new
ovos_utils.fakebus
imports across test files - The aliasing pattern (
FakeMessage as Message
) is used where needed
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for other instances of deprecated imports and verify new import usage
# Check for any remaining deprecated imports
echo "Checking for remaining deprecated messagebus imports..."
rg "from ovos_utils.messagebus import (Message|FakeBus)"
# Verify consistent usage of new imports across tests
echo "Checking for new fakebus import pattern..."
rg "from ovos_utils.fakebus import"
Length of output: 907
test/backwards_compat/test_ocp.py (1)
20-20
: LGTM! Import updated correctly.
The import has been properly updated from ovos_utils.messagebus
to ovos_utils.fakebus
as per the PR objectives.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #611 +/- ##
==========================================
- Coverage 75.33% 73.13% -2.21%
==========================================
Files 15 15
Lines 3094 1526 -1568
==========================================
- Hits 2331 1116 -1215
+ Misses 763 410 -353
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Summary by CodeRabbit
Bug Fixes
FakeBus
andMessage
across various test files to reflect new module organization.Refactor
TestSkillManager
to simplify test setup.These changes improve the reliability and maintainability of the testing framework while ensuring consistent behavior across tests.