mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Resolve all django deprecation warnings
This commit is contained in:
parent
91b97fc05f
commit
be5f289a8a
8 changed files with 29 additions and 30 deletions
|
|
@ -51,33 +51,38 @@ class TestAccountSessionHandler(TestCase):
|
|||
"Check count method"
|
||||
self.assertEqual(self.handler.count(), len(self.handler.get()))
|
||||
|
||||
|
||||
class TestDefaultAccount(TestCase):
|
||||
"Check DefaultAccount class"
|
||||
|
||||
def setUp(self):
|
||||
self.s1 = Session()
|
||||
self.s1.puppet = None
|
||||
self.s1.sessid = 0
|
||||
|
||||
|
||||
def test_password_validation(self):
|
||||
"Check password validators deny bad passwords"
|
||||
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9), email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9),
|
||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
for bad in ('', '123', 'password', 'TestAccount', '#', 'xyzzy'):
|
||||
self.assertFalse(self.account.validate_password(bad, account=self.account)[0])
|
||||
|
||||
|
||||
"Check validators allow sufficiently complex passwords"
|
||||
for better in ('Mxyzptlk', "j0hn, i'M 0n1y d4nc1nG"):
|
||||
self.assertTrue(self.account.validate_password(better, account=self.account)[0])
|
||||
|
||||
self.account.delete()
|
||||
|
||||
def test_password_change(self):
|
||||
"Check password setting and validation is working as expected"
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9), email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9),
|
||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
# Try setting some bad passwords
|
||||
for bad in ('', '#', 'TestAccount', 'password'):
|
||||
self.assertRaises(ValidationError, self.account.set_password, bad)
|
||||
|
||||
|
||||
# Try setting a better password (test for False; returns None on success)
|
||||
self.assertFalse(self.account.set_password('Mxyzptlk'))
|
||||
|
||||
|
|
@ -88,7 +93,7 @@ class TestDefaultAccount(TestCase):
|
|||
DefaultAccount().puppet_object(self.s1, None)
|
||||
self.fail("Expected error: 'Object not found'")
|
||||
except RuntimeError as re:
|
||||
self.assertEqual("Object not found", re.message)
|
||||
self.assertEqual("Object not found", str(re))
|
||||
|
||||
def test_puppet_object_no_session(self):
|
||||
"Check puppet_object method called with no session param"
|
||||
|
|
@ -97,7 +102,7 @@ class TestDefaultAccount(TestCase):
|
|||
DefaultAccount().puppet_object(None, Mock())
|
||||
self.fail("Expected error: 'Session not found'")
|
||||
except RuntimeError as re:
|
||||
self.assertEqual("Session not found", re.message)
|
||||
self.assertEqual("Session not found", str(re))
|
||||
|
||||
def test_puppet_object_already_puppeting(self):
|
||||
"Check puppet_object method called, already puppeting this"
|
||||
|
|
@ -180,4 +185,4 @@ class TestDefaultAccount(TestCase):
|
|||
|
||||
account.puppet_object(self.s1, obj)
|
||||
self.assertTrue(self.s1.data_out.call_args[1]['text'].endswith("is already puppeted by another Account."))
|
||||
self.assertIsNone(obj.at_post_puppet.call_args)
|
||||
self.assertIsNone(obj.at_post_puppet.call_args)
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ class Migration(migrations.Migration):
|
|||
('db_persistent', models.BooleanField(default=False, verbose_name=b'survive server reboot')),
|
||||
('db_is_active', models.BooleanField(default=False, verbose_name=b'script active')),
|
||||
('db_attributes', models.ManyToManyField(help_text=b'attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).', to='typeclasses.Attribute', null=True)),
|
||||
('db_obj', models.ForeignKey(blank=True, to='objects.ObjectDB', help_text=b'the object to store this script on, if not a global script.', null=True, verbose_name=b'scripted object')),
|
||||
('db_account', models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, help_text=b'the account to store this script on (should not be set if obj is set)', null=True, verbose_name=b'scripted account')),
|
||||
('db_obj', models.ForeignKey(blank=True, to='objects.ObjectDB', on_delete=models.CASCADE, help_text=b'the object to store this script on, if not a global script.', null=True, verbose_name=b'scripted object')),
|
||||
('db_account', models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE, help_text=b'the account to store this script on (should not be set if obj is set)', null=True, verbose_name=b'scripted account')),
|
||||
('db_tags', models.ManyToManyField(help_text=b'tags on this object. Tags are simple string markers to identify, group and alias objects.', to='typeclasses.Tag', null=True)),
|
||||
],
|
||||
options={
|
||||
|
|
|
|||
|
|
@ -83,9 +83,11 @@ class ScriptDB(TypedObject):
|
|||
# optional description.
|
||||
db_desc = models.CharField('desc', max_length=255, blank=True)
|
||||
# A reference to the database object affected by this Script, if any.
|
||||
db_obj = models.ForeignKey("objects.ObjectDB", null=True, blank=True, verbose_name='scripted object',
|
||||
db_obj = models.ForeignKey("objects.ObjectDB", null=True, blank=True, on_delete=models.CASCADE,
|
||||
verbose_name='scripted object',
|
||||
help_text='the object to store this script on, if not a global script.')
|
||||
db_account = models.ForeignKey("accounts.AccountDB", null=True, blank=True, verbose_name="scripted account",
|
||||
db_account = models.ForeignKey("accounts.AccountDB", null=True, blank=True,
|
||||
on_delete=models.CASCADE, verbose_name="scripted account",
|
||||
help_text='the account to store this script on (should not be set if db_obj is set)')
|
||||
|
||||
# how often to run Script (secs). -1 means there is no timer
|
||||
|
|
|
|||
|
|
@ -5,10 +5,6 @@ from django.db.models.manager import Manager
|
|||
|
||||
|
||||
class SharedMemoryManager(Manager):
|
||||
# CL: this ensures our manager is used when accessing instances via
|
||||
# ForeignKey etc. (see docs)
|
||||
use_for_related_fields = True
|
||||
|
||||
# TODO: improve on this implementation
|
||||
# We need a way to handle reverse lookups so that this model can
|
||||
# still use the singleton cache, but the active model isn't required
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ class RegularCategory(models.Model):
|
|||
|
||||
class Article(SharedMemoryModel):
|
||||
name = models.CharField(max_length=32)
|
||||
category = models.ForeignKey(Category)
|
||||
category2 = models.ForeignKey(RegularCategory)
|
||||
category = models.ForeignKey(Category, on_delete=models.CASCADE)
|
||||
category2 = models.ForeignKey(RegularCategory, on_delete=models.CASCADE)
|
||||
|
||||
|
||||
class RegularArticle(models.Model):
|
||||
name = models.CharField(max_length=32)
|
||||
category = models.ForeignKey(Category)
|
||||
category2 = models.ForeignKey(RegularCategory)
|
||||
category = models.ForeignKey(Category, on_delete=models.CASCADE)
|
||||
category2 = models.ForeignKey(RegularCategory, on_delete=models.CASCADE)
|
||||
|
||||
|
||||
class SharedMemorysTest(TestCase):
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ urlpatterns = [
|
|||
url(r'^', include('evennia.web.website.urls')), # , namespace='website', app_name='website')),
|
||||
|
||||
# webclient
|
||||
url(r'^webclient/', include('evennia.web.webclient.urls', namespace='webclient', app_name='webclient')),
|
||||
url(r'^webclient/', include('evennia.web.webclient.urls', namespace='webclient')),
|
||||
|
||||
# favicon
|
||||
url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico', permanent=False))
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ webpage 'application'.
|
|||
from django.conf.urls import *
|
||||
from evennia.web.webclient import views as webclient_views
|
||||
|
||||
app_name = "webclient"
|
||||
urlpatterns = [
|
||||
url(r'^$', webclient_views.webclient, name="index")]
|
||||
|
|
|
|||
|
|
@ -8,11 +8,6 @@ from django.conf.urls import url, include
|
|||
from django import views as django_views
|
||||
from evennia.web.website import views as website_views
|
||||
|
||||
# loop over all settings.INSTALLED_APPS and execute code in
|
||||
# files named admin.py in each such app (this will add those
|
||||
# models to the admin site)
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', website_views.page_index, name="index"),
|
||||
url(r'^tbi/', website_views.to_be_implemented, name='to_be_implemented'),
|
||||
|
|
@ -34,7 +29,7 @@ if settings.EVENNIA_ADMIN:
|
|||
url('^admin/$', website_views.evennia_admin, name="evennia_admin"),
|
||||
|
||||
# Makes sure that other admin pages get loaded.
|
||||
url(r'^admin/', include(admin.site.urls))]
|
||||
url(r'^admin/', admin.site.urls)]
|
||||
else:
|
||||
# Just include the normal Django admin.
|
||||
urlpatterns += [url(r'^admin/', include(admin.site.urls))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue