Beispiel #1
0
	def testItem(self):
		p = Rock()
		GameUtil.save()
		p.destroy()
		GameUtil.save()
		self.cur.execute("SELECT COUNT(*) FROM item")
		row = self.cur.fetchone()
		self.assert_(row is not None)
		self.assertEqual(row[0], 0)
Beispiel #2
0
 def testAddItems(self):
     ilist = (self.rock, self.gp3, Rock())
     self.p1.inventory.add_items(ilist)
     self.assert_(self.p1.inventory.has(Rock, 2))
     self.failIf(self.p1.inventory.has(Rock, 3))
     self.assert_(self.p1.inventory.has(GoldPiece, 3))
     self.failIf(self.p1.inventory.has(GoldPiece, 4))
Beispiel #3
0
 def testRetrieveByName(self):
     self.p1.inventory.add(self.rock)
     otherrock = Rock()
     self.p1.inventory.add(otherrock)
     iset = self.p1.inventory["Rock"]
     self.assertEqual(len(iset), 2)
     self.assert_(self.rock._id in iset)
     self.assert_(otherrock._id in iset)
Beispiel #4
0
 def testTakeBasic(self):
     self.p1.inventory.add(self.rock)
     otherrock = Rock()
     self.p1.inventory.add(otherrock)
     ilist = self.p1.inventory.take(Rock, 2)
     self.assertEqual(len(ilist), 2)
     self.assert_(self.rock in ilist)
     self.assert_(otherrock in ilist)
Beispiel #5
0
 def testHasBasicNegativeMany(self):
     self.p1.inventory.add(self.rock)
     self.p1.inventory.add(Rock())
     self.failIf(self.p1.inventory.has(Rock, 3))
Beispiel #6
0
 def testHasBasicPositiveMany(self):
     self.p1.inventory.add(self.rock)
     self.p1.inventory.add(Rock())
     self.assert_(self.p1.inventory.has(Rock, 2))
Beispiel #7
0
 def setUp(self):
     TestDatabaseSetup.setUp(self)
     self.p1 = Player("Vladimir", Alignment.WOOD)
     self.p2 = Player("Estragon", Alignment.METAL)
     self.rock = Rock()
     self.gp3 = GoldPiece(3)