~divmod-dev/divmod.org/empty-host-header-2936

« back to all changes in this revision

Viewing changes to Imaginary/imaginary/test/test_put.py

  • Committer: glyph
  • Date: 2009-06-29 04:03:17 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:17590
Remove all usage of `installOn()` from Imaginary.

This change replaces the undocumented `ThingMixin`, and the unfortunately-named, poorly-considered idiom of using `installOn` with its subclasses, with a new, thoroughly documented and better-named mixin, `imaginary.enhancement.Enhancement`.

Furthermore, this updates `createCreator` to use `Enhancement`s rather than arbitrary powerups.

The tests and included systems now also provide a good example of how Imaginary application / game code should idiomatically fit into the framework.

Author: glyph

Reviewer: exarkun

Fixes #2558

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
from twisted.trial import unittest
3
3
 
4
 
from axiom.dependency import installOn
5
 
 
6
4
from imaginary.test import commandutils
7
 
from imaginary import iimaginary, objects
 
5
from imaginary import objects
8
6
 
9
7
class PutTestCase(commandutils.CommandTestCaseMixin, unittest.TestCase):
10
8
    def setUp(self):
12
10
        self.object = objects.Thing(store=self.store, name=u"foo")
13
11
        self.object.moveTo(self.player)
14
12
        self.container = objects.Thing(store=self.store, name=u"bar")
15
 
        self.containerContainer = objects.Container(store=self.store, capacity=1)
16
 
        installOn(self.containerContainer, self.container)
 
13
        self.containerContainer = objects.Container.createFor(self.container, capacity=1)
17
14
        self.container.moveTo(self.location)
18
15
        return r
19
16
 
61
58
 
62
59
    def testNestedContainment(self):
63
60
        another = objects.Thing(store=self.store, name=u"another")
64
 
        installOn(objects.Container(store=self.store, capacity=1), another)
 
61
        objects.Container.createFor(another, capacity=1)
65
62
        self.containerContainer.add(another)
66
63
 
67
64
        self._test(
74
71
 
75
72
    def testIndirectNestedContainment(self):
76
73
        innermost = objects.Thing(store=self.store, name=u"innermost")
77
 
        innermostContainer = objects.Container(store=self.store, capacity=1)
78
 
        installOn(innermostContainer, innermost)
 
74
        innermostContainer = objects.Container.createFor(innermost, capacity=1)
79
75
        middle = objects.Thing(store=self.store, name=u"middle")
80
 
        middleContainer = objects.Container(store=self.store, capacity=1)
81
 
        installOn(middleContainer, middle)
 
76
        middleContainer = objects.Container.createFor(middle, capacity=1)
82
77
        middleContainer.add(innermost)
83
78
        self.containerContainer.add(middle)
84
79