mirror of
https://github.com/evennia/evennia.git
synced 2025-10-29 19:35:56 +00:00
GLOBAL_SCRIPTS.all() failed. Resolve #3788
This commit is contained in:
parent
0779ec82b6
commit
27931248ec
@ -49,6 +49,7 @@ This upgrade requires running `evennia migrate` on your existing database
|
||||
- [Fix][pull3751]: The `access` and `inventory` commands would traceback if run on a character without an Account (EliasWatson)
|
||||
- [Fix][pull3768]: Make sure the `CmdCopy` command copies object categories,
|
||||
since otherwise plurals were lost (jaborsh)
|
||||
- [Fix][issue3788]: `GLOBAL_SCRIPTS.all()` raised error (Griatch)
|
||||
- Fix: `options` setting `NOPROMPTGOAHEAD` was not possible to set (Griatch)
|
||||
- Fix: Make `\\` properly preserve one backlash in funcparser (Griatch)
|
||||
- Fix: The testing 'echo' inputfunc didn't work correctly; now returns both args/kwargs (Griatch)
|
||||
@ -88,6 +89,7 @@ This upgrade requires running `evennia migrate` on your existing database
|
||||
[pull3783]: https://github.com/evennia/evennia/pull/3783
|
||||
[issue3688]: https://github.com/evennia/evennia/issues/3688
|
||||
[issue3687]: https://github.com/evennia/evennia/issues/3687
|
||||
[issue3788]: https://github.com/evennia/evennia/issues/3788
|
||||
|
||||
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@ therefore always be limited to superusers only.
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.utils import logger, utils
|
||||
from evennia.utils.batchprocessors import BATCHCMD, BATCHCODE
|
||||
@ -412,7 +411,7 @@ class CmdStateLL(_COMMAND_DEFAULT_CLASS):
|
||||
|
||||
key = "ll"
|
||||
help_category = "BatchProcess"
|
||||
locks = "cmd:perm(batchcommands)"
|
||||
locks = "cmd:perm(batchcommands) or perm(Developer)"
|
||||
|
||||
def func(self):
|
||||
show_curr(self.caller, showall=True)
|
||||
|
||||
@ -14,7 +14,6 @@ from pickle import dumps
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.utils import OperationalError, ProgrammingError
|
||||
|
||||
from evennia.scripts.models import ScriptDB
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.utils import callables_from_module, class_from_module
|
||||
@ -250,7 +249,7 @@ class GlobalScriptContainer(Container):
|
||||
"""
|
||||
if not self.loaded:
|
||||
self.load_data()
|
||||
managed_scripts = list(self.loaded_data.values())
|
||||
managed_scripts = [self._load_script(key) for key in self.typeclass_storage.keys()]
|
||||
unmanaged_scripts = list(
|
||||
ScriptDB.objects.filter(db_obj__isnull=True).exclude(
|
||||
id__in=[scr.id for scr in managed_scripts]
|
||||
|
||||
@ -2,7 +2,6 @@ import unittest
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import override_settings
|
||||
|
||||
from evennia import DefaultScript
|
||||
from evennia.utils import containers
|
||||
from evennia.utils.utils import class_from_module
|
||||
@ -10,15 +9,16 @@ from evennia.utils.utils import class_from_module
|
||||
_BASE_TYPECLASS = class_from_module(settings.BASE_SCRIPT_TYPECLASS)
|
||||
|
||||
|
||||
class GoodScript(DefaultScript):
|
||||
class UnittestGoodScript(DefaultScript):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidScript:
|
||||
class UnittestInvalidScript:
|
||||
pass
|
||||
|
||||
|
||||
class TestGlobalScriptContainer(unittest.TestCase):
|
||||
|
||||
def test_init_with_no_scripts(self):
|
||||
gsc = containers.GlobalScriptContainer()
|
||||
|
||||
@ -60,7 +60,7 @@ class TestGlobalScriptContainer(unittest.TestCase):
|
||||
|
||||
@override_settings(
|
||||
GLOBAL_SCRIPTS={
|
||||
"script_name": {"typeclass": "evennia.utils.tests.test_containers.GoodScript"}
|
||||
"script_name": {"typeclass": "evennia.utils.tests.test_containers.UnittestGoodScript"}
|
||||
}
|
||||
)
|
||||
def test_start_with_valid_script(self):
|
||||
@ -70,11 +70,13 @@ class TestGlobalScriptContainer(unittest.TestCase):
|
||||
|
||||
self.assertEqual(len(gsc.typeclass_storage), 1)
|
||||
self.assertIn("script_name", gsc.typeclass_storage)
|
||||
self.assertEqual(gsc.typeclass_storage["script_name"], GoodScript)
|
||||
self.assertEqual(gsc.typeclass_storage["script_name"], UnittestGoodScript)
|
||||
|
||||
@override_settings(
|
||||
GLOBAL_SCRIPTS={
|
||||
"script_name": {"typeclass": "evennia.utils.tests.test_containers.InvalidScript"}
|
||||
"script_name": {
|
||||
"typeclass": "evennia.utils.tests.test_containers.UnittestInvalidScript"
|
||||
}
|
||||
}
|
||||
)
|
||||
def test_start_with_invalid_script(self):
|
||||
@ -85,7 +87,7 @@ class TestGlobalScriptContainer(unittest.TestCase):
|
||||
gsc.start()
|
||||
# check for general attribute failure on the invalid class to preserve against future code-rder changes
|
||||
self.assertTrue(
|
||||
str(err.exception).startswith("type object 'InvalidScript' has no attribute"),
|
||||
str(err.exception).startswith("type object 'UnittestInvalidScript' has no attribute"),
|
||||
err.exception,
|
||||
)
|
||||
|
||||
@ -105,3 +107,24 @@ class TestGlobalScriptContainer(unittest.TestCase):
|
||||
str(err.exception).startswith("cannot import name 'nonexistent_module' from 'evennia'"),
|
||||
err.exception,
|
||||
)
|
||||
|
||||
@override_settings(
|
||||
GLOBAL_SCRIPTS={
|
||||
"script_name": {"typeclass": "evennia.utils.tests.test_containers.UnittestGoodScript"}
|
||||
}
|
||||
)
|
||||
def test_using_global_script__all(self):
|
||||
"""
|
||||
Using the GlobalScriptContainer.all() to get all scripts
|
||||
|
||||
Tests https://github.com/evennia/evennia/issues/3788
|
||||
|
||||
"""
|
||||
from evennia.scripts.models import ScriptDB
|
||||
|
||||
ScriptDB.objects.all().delete() # clean up any old scripts
|
||||
|
||||
gsc = containers.GlobalScriptContainer()
|
||||
script = gsc.get("script_name")
|
||||
result = gsc.all()
|
||||
self.assertEqual(result, [script])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user