mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 18:06:08 -05:00
[Core V3] Make the bot data path configurable (#879)
* Initial commit * Fix sentry * Make cog manager install path work relative to the bot's dir * Fix downloader to save data relative to the defined data folder * Fix sentry test * Fix downloader tests * Change logfile location * Add another line to codeowners * Basic tests * Fix versioning * Add in FutureWarning for config file changes * Add reference to issue
This commit is contained in:
41
tests/core/test_data_manager.py
Normal file
41
tests/core/test_data_manager.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from core import data_manager
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def cleanup_datamanager():
|
||||
data_manager.basic_config = None
|
||||
data_manager.jsonio = None
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def data_mgr_config(tmpdir):
|
||||
default = data_manager.basic_config_default.copy()
|
||||
default['BASE_DIR'] = str(tmpdir)
|
||||
return default
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def cog_instance():
|
||||
thing = type('CogTest', (object, ), {})
|
||||
return thing()
|
||||
|
||||
|
||||
def test_no_basic(cog_instance):
|
||||
with pytest.raises(RuntimeError):
|
||||
data_manager.core_data_path()
|
||||
|
||||
with pytest.raises(RuntimeError):
|
||||
data_manager.cog_data_path(cog_instance)
|
||||
|
||||
|
||||
def test_core_path(data_mgr_config, tmpdir):
|
||||
conf_path = tmpdir.join('config.json')
|
||||
conf_path.write(json.dumps(data_mgr_config))
|
||||
|
||||
data_manager.load_basic_configuration(Path(str(conf_path)))
|
||||
|
||||
assert data_manager.core_data_path().parent == Path(data_mgr_config['BASE_DIR'])
|
||||
@@ -2,9 +2,9 @@ from core import sentry_setup
|
||||
import logging
|
||||
|
||||
|
||||
def test_sentry_capture():
|
||||
def test_sentry_capture(red):
|
||||
log = logging.getLogger(__name__)
|
||||
sentry_setup.init_sentry_logging(log)
|
||||
sentry_setup.init_sentry_logging(red, log)
|
||||
|
||||
assert sentry_setup.client is not None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user