mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3 Config] Fix unloading and implement singleton driver (#1458)
* Add the identifier as an initialization parameter * Remove config object singleton and opt for a shared JSON datastore * Fix bot unloading to deal with memory leaks * Fix tests * Fix clear all bug
This commit is contained in:
@@ -38,6 +38,7 @@ def json_driver(tmpdir_factory):
|
||||
path = Path(str(tmpdir_factory.mktemp(rand)))
|
||||
driver = red_json.JSON(
|
||||
"PyTest",
|
||||
identifier=str(uuid.uuid4()),
|
||||
data_path_override=path
|
||||
)
|
||||
return driver
|
||||
@@ -45,10 +46,9 @@ def json_driver(tmpdir_factory):
|
||||
|
||||
@pytest.fixture()
|
||||
def config(json_driver):
|
||||
import uuid
|
||||
conf = Config(
|
||||
cog_name="PyTest",
|
||||
unique_identifier=str(uuid.uuid4()),
|
||||
unique_identifier=json_driver.unique_cog_identifier,
|
||||
driver=json_driver)
|
||||
yield conf
|
||||
conf._defaults = {}
|
||||
@@ -59,10 +59,9 @@ def config_fr(json_driver):
|
||||
"""
|
||||
Mocked config object with force_register enabled.
|
||||
"""
|
||||
import uuid
|
||||
conf = Config(
|
||||
cog_name="PyTest",
|
||||
unique_identifier=str(uuid.uuid4()),
|
||||
unique_identifier=json_driver.unique_cog_identifier,
|
||||
driver=json_driver,
|
||||
force_registration=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user