Skip to content

Commit

Permalink
drop mycroft-core config location (#90)
Browse files Browse the repository at this point in the history
* drop mycroft-core config location

* derprecated util

* derprecated util

* derprecated util
  • Loading branch information
JarbasAl authored Dec 28, 2023
1 parent 6654199 commit 0b16d46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 42 deletions.
15 changes: 1 addition & 14 deletions ovos_config/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,7 @@ def get_xdg_config_locations():


def find_default_config():
""" find where mycroft is installed and return the path to the default mycroft.conf
if mycroft is not found then return the bundled file in ovos_config package"""
from ovos_utils.system import search_mycroft_core_location
try:
mycroft_root = search_mycroft_core_location()
if not mycroft_root:
raise FileNotFoundError("Couldn't find mycroft core root folder.")
cfg = join(mycroft_root, "mycroft", "configuration", "mycroft.conf")
if isfile(cfg):
return cfg
except FileNotFoundError:
pass

# mycroft-core not found
"""return the bundled file in ovos_config package"""
return join(dirname(__file__), "mycroft.conf")


Expand Down
31 changes: 3 additions & 28 deletions test/unittests/test_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,13 @@ def test_get_config_locations(self, config_path, webcache_loc,
['/test/default.yml', '/etc/test/test.yaml',
'webcache', '~/.test/test.yaml', 'config/test.yaml'])

@mock.patch("ovos_utils.system.search_mycroft_core_location")
def test_find_default_config(self, get_core):
from ovos_config.locations import find_default_config

# No Core
get_core.return_value = None
no_core_default = find_default_config()
self.assertTrue(no_core_default.endswith("/ovos_config/mycroft.conf"),
no_core_default)
self.assertTrue(isfile(no_core_default), no_core_default)

# # Invalid Core
# get_core.return_value = "/tmp"
# self.assertEqual(find_default_config(),
# "/tmp/mycroft/configuration/mycroft.conf")

# Valid Core
get_core.return_value = dirname(__file__)
self.assertEqual(find_default_config(),
join(dirname(__file__), "mycroft", "configuration",
"mycroft.conf"))

@mock.patch("ovos_utils.system.search_mycroft_core_location")

@mock.patch("ovos_config.meta.get_config_filename")
@mock.patch("ovos_config.meta.get_xdg_base")
@mock.patch("ovos_utils.system.is_running_from_module")
@mock.patch("os.path.isfile")
def test_globals(self, fcheck, mod_check, xdg_base, config_filename, core_location):
def test_globals(self, fcheck, mod_check, xdg_base, config_filename):
fcheck.return_value = True
core_location.return_value = "default/config/path"
xdg_base.return_value = "test"
config_filename.return_value = "test.yaml"
mod_check.return_value = False
Expand All @@ -111,9 +88,7 @@ def test_globals(self, fcheck, mod_check, xdg_base, config_filename, core_locati
# Test all config paths respect environment overrides/configured values
from ovos_config.locations import DEFAULT_CONFIG, SYSTEM_CONFIG, \
OLD_USER_CONFIG, USER_CONFIG, REMOTE_CONFIG, WEB_CONFIG_CACHE
self.assertEqual(DEFAULT_CONFIG,
"default/config/path/mycroft/configuration"
"/mycroft.conf")

self.assertEqual(SYSTEM_CONFIG, "mycroft/system/config")
self.assertEqual(OLD_USER_CONFIG,
expanduser("~/.test/test.yaml"))
Expand Down

0 comments on commit 0b16d46

Please sign in to comment.