Skip to content

Commit

Permalink
adjust unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoYangyang0403 committed Aug 15, 2023
1 parent bd81e42 commit 8341fc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lyrebird/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,16 @@ class ConfigException(Exception):


class PersonalConfigManager():
ROOT = Path('~/.lyrebird').expanduser()
DEFAULT_FILENAME = 'personal_conf.json'
PERSONAL_CONFIG = ROOT / DEFAULT_FILENAME

def __init__(self):
def __init__(self, root_dir=None):
if root_dir:
ROOT = root_dir
else:
ROOT = Path('~/.lyrebird').expanduser()
DEFAULT_FILENAME = 'personal_conf.json'
PERSONAL_CONFIG = ROOT / DEFAULT_FILENAME

self.personal_conf_init = personal_config_template
self.personal_conf_file = self.PERSONAL_CONFIG
self.personal_conf_file = PERSONAL_CONFIG

if not self.personal_conf_file.exists():
self.write_config(self.personal_conf_init)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from lyrebird import reporter, application
from lyrebird.event import EventServer
from lyrebird.task import BackgroundTaskServer
from lyrebird.config import PersonalConfigManager
from lyrebird.db.database_server import LyrebirdDatabaseServer


Expand All @@ -26,6 +27,7 @@ def event_server(tmpdir):
'mock.port': 9090
}
application._cm = MockConfigManager(config=_conf, ROOT=Path(tmpdir), root=Path(tmpdir))
PersonalConfigManager(root_dir=application.root_dir())
lyrebird.mock.context.application.socket_io = FakeSocketio()
server = EventServer()
server.start()
Expand Down

0 comments on commit 8341fc3

Please sign in to comment.