-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implement module_property decorator with unit test #103
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import unittest | ||
|
||
|
||
class TestSystem(unittest.TestCase): | ||
def test_is_running_from_module(self): | ||
from ovos_utils.system import is_running_from_module | ||
self.assertFalse(is_running_from_module("mycroft")) | ||
self.assertTrue(is_running_from_module("unittest")) | ||
|
||
def test_ntp_sync(self): | ||
# TODO | ||
pass | ||
|
||
def test_system_shutdown(self): | ||
# TODO | ||
pass | ||
|
||
def test_system_reboot(self): | ||
# TODO | ||
pass | ||
|
||
def test_ssh_enable(self): | ||
# TODO | ||
pass | ||
|
||
def test_ssh_disable(self): | ||
# TODO | ||
pass | ||
|
||
def test_restart_mycroft_service(self): | ||
# TODO | ||
pass | ||
|
||
def test_restart_service(self): | ||
# TODO | ||
pass | ||
|
||
def test_enable_service(self): | ||
# TODO | ||
pass | ||
|
||
def test_disable_service(self): | ||
# TODO | ||
pass | ||
|
||
def test_check_service_active(self): | ||
# TODO | ||
pass | ||
|
||
def test_set_root_path(self): | ||
from ovos_utils.system import set_root_path | ||
set_root_path("test") | ||
from ovos_utils.system import _USER_DEFINED_ROOT | ||
self.assertEqual(_USER_DEFINED_ROOT, "test") | ||
set_root_path("mycroft") | ||
from ovos_utils.system import _USER_DEFINED_ROOT | ||
self.assertEqual(_USER_DEFINED_ROOT, "mycroft") | ||
set_root_path(None) | ||
from ovos_utils.system import _USER_DEFINED_ROOT | ||
self.assertIsNone(_USER_DEFINED_ROOT) | ||
|
||
def test_find_root_from_sys_path(self): | ||
# TODO | ||
pass | ||
|
||
def test_find_root_from_sitepackages(self): | ||
# TODO | ||
pass | ||
|
||
def test_search_mycroft_core_location(self): | ||
# TODO | ||
pass | ||
|
||
def test_get_desktop_environment(self): | ||
# TODO | ||
pass | ||
|
||
def test_is_process_running(self): | ||
# TODO | ||
pass | ||
|
||
def test_find_executable(self): | ||
# TODO | ||
pass | ||
|
||
def test_is_installed(self): | ||
# TODO | ||
pass | ||
|
||
def test_has_screen(self): | ||
# TODO | ||
pass | ||
|
||
def test_module_property(self): | ||
import sys | ||
from ovos_utils.system import module_property | ||
|
||
test_val = True | ||
|
||
@module_property | ||
def _mock_property(): | ||
return test_val | ||
|
||
test_module = sys.modules[self.__module__] | ||
self.assertTrue(test_module.mock_property) | ||
|
||
test_val = False | ||
self.assertFalse(test_module.mock_property) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
_USER_DEFINED_ROOT could be a module property now ?
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.
I wasn't sure how much this is used, but I can test that change
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.
This doesn't actually change behavior, only adds a wrapper method since the property is evaluated upon import, not reference. Since it's already marked as an internal variable, I'll leave it