示例#1
0
文件: unit.py 项目: Neamar/kingdoms
	def test_token_to_pending_event_from_category(self):
		"""
		Check token validates condition for specified pending_event
		"""

		pet = PendingEventToken(
			kingdom=self.k,
			category=self.c
		)
		pet.save()

		# Should fallback to other events in the category
		ret = pet.to_event()
		self.assertEquals(ret.event, self.e)
示例#2
0
文件: unit.py 项目: Neamar/kingdoms
	def test_token_to_pending_event_from_invalid_category(self):
		"""
		Check token validates condition for specified pending_event
		"""
		self.e.condition = "stop('nope')"
		self.e.save()

		pet = PendingEventToken(
			kingdom=self.k,
			category=self.c
		)
		pet.save()

		# Should fallback to other events in the category
		self.assertRaises(ValidationError, pet.to_event)
示例#3
0
文件: unit.py 项目: Neamar/kingdoms
	def test_token_to_pending_event_from_pending_event(self):
		"""
		Check token is made into specified pending_event
		"""

		pe = PendingEvent(
			event=self.e,
			kingdom=self.k,
			started=None
		)
		pe.save()

		pet = PendingEventToken(
			kingdom=self.k,
			pending_event=pe,
			category=self.c
		)
		pet.save()

		self.assertEqual(pet.to_event(), pe)
示例#4
0
文件: unit.py 项目: Neamar/kingdoms
	def test_token_to_pending_event_from_invalid_pending_event(self):
		"""
		Check token validates condition for specified pending_event
		"""

		self.e.condition = "stop('nope')"
		self.e.save()

		e2 = Event(
			name="Event 2",
			slug="event_2",
			category=self.c,
			text="Event 2",
			on_fire=""
		)
		e2.save()

		pe = PendingEvent(
			event=self.e,
			kingdom=self.k,
			started=None
		)
		pe.save()

		pet = PendingEventToken(
			kingdom=self.k,
			pending_event=pe,
			category=self.c
		)
		pet.save()

		# Should fallback to other events in the category
		ret = pet.to_event()
		self.assertEquals(ret.event, e2)

		# Check pe has been deleted
		self.assertIsNone(pe.pk)