Skip to content

Commit

Permalink
deprecate!:backend client
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 18, 2024
1 parent bdaee47 commit 193df9e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 50 deletions.
16 changes: 1 addition & 15 deletions ovos_workshop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@
class OVOSAbstractApplication(OVOSSkill):
def __init__(self, skill_id: str, bus: Optional[MessageBusClient] = None,
resources_dir: Optional[str] = None,
lang=None, settings: Optional[dict] = None,
gui: Optional[GUIInterface] = None,
enable_settings_manager: bool = False, **kwargs):
gui: Optional[GUIInterface] = None, **kwargs):
"""
Create an Application. An application is essentially a skill, but
designed such that it may be run without an intent service.
@param skill_id: Unique ID for this application
@param bus: MessageBusClient to bind to application
@param resources_dir: optional root resource directory (else defaults to
application `root_dir`
@param lang: DEPRECATED language of the application
@param settings: DEPRECATED settings object
@param gui: GUIInterface to bind (if `None`, one is created)
@param enable_settings_manager: if True, enables a SettingsManager for
this application to manage default settings and backend sync
"""
self._dedicated_bus = False
if bus:
Expand All @@ -38,15 +32,7 @@ def __init__(self, skill_id: str, bus: Optional[MessageBusClient] = None,

super().__init__(skill_id=skill_id, bus=bus, gui=gui,
resources_dir=resources_dir,
enable_settings_manager=enable_settings_manager,
**kwargs)

if settings:
log_deprecation(f"Settings should be set in {self.settings_path}. "
f"Passing `settings` to __init__ is not supported.",
"0.1.0")
self.settings.merge(settings)

@property
def settings_path(self) -> str:
"""
Expand Down
10 changes: 0 additions & 10 deletions test/unittests/skills/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,18 @@ def test_upload_settings(self):
pass

def test_handle_settings_file_change(self):
real_upload = self.skill._upload_settings
self.skill._upload_settings = Mock()
settings_file = self.skill.settings.path

# Handle change with no callback
self.skill._handle_settings_file_change(settings_file)
self.skill._upload_settings.assert_called_once()

# Handle change with callback
self.skill._upload_settings.reset_mock()
self.skill.settings_change_callback = Mock()
self.skill._handle_settings_file_change(settings_file)
self.skill._upload_settings.assert_called_once()
self.skill.settings_change_callback.assert_called_once()

# Handle non-settings file change
self.skill._handle_settings_file_change(join(dirname(settings_file),
"test.file"))
self.skill._upload_settings.assert_called_once()
self.skill.settings_change_callback.assert_called_once()

self.skill._upload_settings = real_upload

def test_load_lang(self):
# TODO
Expand Down
26 changes: 1 addition & 25 deletions test/unittests/test_abstract_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,9 @@ def __int__(self, *args, **kwargs):
class TestApp(unittest.TestCase):
bus = FakeBus()

test_path = join(dirname(__file__), "test_config.json")
settings = {'test': True,
'updated': False}
settings_obj = JsonStorage(test_path, True)
settings_obj.update(settings)

gui = GUIInterface("TestApplication")

app = Application(skill_id="TestApplication", settings=settings_obj,
gui=gui, bus=bus)

def test_settings_manager_init(self):
self.assertIsNone(self.app.settings_manager)

def test_settings_init(self):
self.assertNotEqual(self.app.settings, self.settings_obj)
self.assertFalse(self.app.settings['__mycroft_skill_firstrun'])
self.assertTrue(self.app.settings['test'])
self.assertFalse(self.app.settings['updated'])
self.settings_obj['updated'] = True
self.assertFalse(self.app.settings['updated'])

def test_settings_init_invalid_arg(self):
app = Application(skill_id="TestApplication", bus=self.bus,
settings=self.settings)
self.assertNotEqual(app.settings, self.settings)
self.assertFalse(app.settings['__mycroft_skill_firstrun'])
app = Application(skill_id="TestApplication", gui=gui, bus=bus)

def test_gui_init(self):
self.assertEqual(self.app.gui, self.gui)
Expand Down

0 comments on commit 193df9e

Please sign in to comment.