evennia/src/objects/tests.py
Griatch 08b3de9e5e OBS: You'll need to resync/rebuild your database!
- This implements an updated, clearer and more robust access system. The policy is now to lock that which is not explicitly left open.
- Permission strings -> Lock strings. Separating permissions and locks makes more sense security-wise
- No more permissiongroup table; permissions instead use a simple tuple PERMISSIONS_HIERARCHY to define an access hierarchy
- Cleaner lock-definition syntax, all based on function calls.
- New objects/players/channels get a default security policy during creation (set through typeclass)

As part of rebuilding and testing the new lock/permission system I got into testing and debugging several other systems, fixing some
outstanding issues:
- @reload now fully updates the database asynchronously. No need to reboot server when changing cmdsets
- Dozens of new test suites added for about 30 commands so far
- Help for channels made more clever and informative.
2011-03-15 16:08:32 +00:00

60 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
"""
Unit testing of the 'objects' Evennia component.
Runs as part of the Evennia's test suite with 'manage.py test"
Please add new tests to this module as needed.
Guidelines:
A 'test case' is testing a specific component and is defined as a class inheriting from unittest.TestCase.
The test case class can have a method setUp() that creates and sets up the testing environment.
All methods inside the test case class whose names start with 'test' are used as test methods by the runner.
Inside the test methods, special member methods assert*() are used to test the behaviour.
"""
import sys
try:
from django.utils.unittest import TestCase
except ImportError:
from django.test import TestCase
try:
from django.utils import unittest
except ImportError:
import unittest
from django.conf import settings
from src.objects import models, objects
from src.utils import create
from src.commands.default import tests as commandtests
from src.locks import tests as locktests
class TestObjAttrs(TestCase):
"""
Test aspects of ObjAttributes
"""
def setUp(self):
"set up the test"
self.attr = models.ObjAttribute()
self.obj1 = create.create_object(objects.Object, key="testobj1", location=None)
self.obj2 = create.create_object(objects.Object, key="testobj2", location=self.obj1)
def test_store_str(self):
hstring = "sdfv00=97sfjs842 ivfjlQKFos9GF^8dddsöäå-?%"
self.obj1.db.testattr = hstring
self.assertEqual(hstring, self.obj1.db.testattr)
def test_store_obj(self):
self.obj1.db.testattr = self.obj2
self.assertEqual(self.obj2 ,self.obj1.db.testattr)
self.assertEqual(self.obj2.location, self.obj1.db.testattr.location)
def suite():
"""
This function is called automatically by the django test runner.
This also runs the command tests defined in src/commands/default/tests.py.
"""
tsuite = unittest.TestSuite()
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__]))
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(commandtests))
tsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(locktests))
return tsuite