~divmod-dev/divmod.org/trunk

« back to all changes in this revision

Viewing changes to Imaginary/ExampleGame/examplegame/test/test_quiche.py

  • Committer: Jean-Paul Calderone
  • Date: 2014-06-29 20:33:04 UTC
  • mfrom: (2749.1.1 remove-epsilon-1325289)
  • Revision ID: exarkun@twistedmatrix.com-20140629203304-gdkmbwl1suei4m97
mergeĀ lp:~exarkun/divmod.org/remove-epsilon-1325289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from twisted.trial import unittest
2
 
 
3
 
from imaginary import objects, iimaginary
4
 
from imaginary.test import commandutils
5
 
 
6
 
from examplegame import quiche
7
 
 
8
 
 
9
 
class VendingTest(commandutils.CommandTestCaseMixin, unittest.TestCase):
10
 
    def testTheyExist(self):
11
 
        self._test("create the 'vending machine' named vendy",
12
 
                   ["You create vendy."],
13
 
                   ["Test Player creates vendy."])
14
 
 
15
 
 
16
 
    def testPopulateVendingMachine(self):
17
 
        self._test("create the 'vending machine' named vendy",
18
 
                   ["You create vendy."],
19
 
                   ["Test Player creates vendy."])
20
 
 
21
 
        self._test("create a quiche named quiche",
22
 
                   ["You create a quiche."],
23
 
                   ["Test Player creates a quiche."])
24
 
 
25
 
        self._test("open vendy",
26
 
                   ["You open vendy."],
27
 
                   ["Test Player opens vendy."])
28
 
 
29
 
        self._test("put quiche in vendy",
30
 
                   ["You put the quiche in vendy."],
31
 
                   ["Test Player puts a quiche in vendy."])
32
 
 
33
 
 
34
 
    def testBuyingQuiche(self):
35
 
        self._test("create the 'vending machine' named vendy",
36
 
                   ["You create vendy."],
37
 
                   ["Test Player creates vendy."])
38
 
 
39
 
        self._test("drop vendy",
40
 
                   ["You drop vendy."],
41
 
                   ["Test Player drops vendy."])
42
 
 
43
 
        self._test("create a quiche named quiche",
44
 
                   ["You create a quiche."],
45
 
                   ["Test Player creates a quiche."])
46
 
 
47
 
        self._test("open vendy",
48
 
                   ["You open vendy."],
49
 
                   ["Test Player opens vendy."])
50
 
 
51
 
        self._test("put quiche in vendy",
52
 
                   ["You put the quiche in vendy."],
53
 
                   ["Test Player puts a quiche in vendy."])
54
 
 
55
 
        for i in range(5):
56
 
            self._test("create the quarter named quarter%s " % i,
57
 
                       ["You create quarter%s." % i],
58
 
                       ["Test Player creates quarter%s." % i])
59
 
 
60
 
        for i in range(4):
61
 
            self._test("put quarter%i in vendy" % i,
62
 
                       ["You put quarter%s in vendy." % i],
63
 
                       ["Test Player puts quarter%s in vendy." % i])
64
 
 
65
 
        self._test("put quarter4 in vendy",
66
 
                   ["You put quarter4 in vendy.",
67
 
                   "Vendy thumps loudly and spits out a quiche onto the ground."],
68
 
                   ["Test Player puts quarter4 in vendy.",
69
 
                    "Vendy thumps loudly and spits out a quiche onto the ground."])
70
 
 
71
 
 
72
 
    def testProgrammaticQuichePurchase(self):
73
 
        location = objects.Thing(store=self.store, name=u"room")
74
 
        icloc = objects.Container.createFor(location, capacity=500)
75
 
 
76
 
        vm = quiche.createVendingMachine(store=self.store, name=u"Vendy", description=u"VEEEENDYYYYY")
77
 
        vm.moveTo(location)
78
 
 
79
 
        icvm = iimaginary.IContainer(vm)
80
 
        icvm.closed = False
81
 
        theQuiche = quiche.createQuiche(store=self.store, name=u"quiche")
82
 
        icvm.add(theQuiche)
83
 
        icvm.closed = True
84
 
 
85
 
        for i in range(4):
86
 
            quarter = quiche.createCoin(store=self.store, name=u"quarter%s" % (i,))
87
 
            icvm.add(quarter)
88
 
 
89
 
        quarter = quiche.createCoin(store=self.store, name=u"quarter4")
90
 
        icvm.add(quarter)
91
 
 
92
 
        self.failUnless(icloc.contains(theQuiche))
93