Exemple #1
0
	def test_pendingevent_set_get_value(self):
		"""
		Test that setting and retrieving a context value through a Pending Event works
		"""

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

		f = Folk(
			kingdom=self.k,
			first_name="Theon",
			last_name="Greyjoy"
		)
		f.save()

		pe.set_value("peon", f)
		self.assertEqual(f, pe.get_value("peon"))

		pe.set_value("Narnia", self.k)
		self.assertEqual(self.k, pe.get_value("Narnia"))

		pe.set_value("nompourri", "Kevin")
		self.assertEqual(pe.get_value("nompourri"), "Kevin")

		pe.set_value("beastnum", 666)
		self.assertEqual(pe.get_value("beastnum"), 666)

		pe.set_value("void", None)
		self.assertEqual(pe.get_value("void"), None)
Exemple #2
0
	def test_templates_and_folk_details_templatetags(self):
		"""
		Check folk_details template_tags.
		"""
		folk = Folk(first_name="septon", sex=Folk.MALE, kingdom=self.k)
		cat  = QualityCategory(name="boa",description="so")
		cat.save()
		quality = Quality(slug="lol",name="sdf",category=cat)
		quality.save()
		folk.save()

		folk.quality_set.add(quality)

		self.e.text = "{{ septon|folk_details }}"
		self.e.save()

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

		pe.save()
		pe.set_value("septon", folk)

		pe.started = datetime.now()
		pe.save()

		self.assertTrue(quality.name in pe.text)
		self.assertTrue(str(folk.fight) in pe.text)
		self.assertTrue("<table>" in pe.text)
Exemple #3
0
	def test_templates_and_feminize_templatetags(self):
		"""
		Check feminize template_tags.
		"""

		f = Folk(first_name="septon", sex=Folk.MALE, kingdom=self.k)
		f.save()
		f2 = Folk(first_name="cersei", sex=Folk.FEMALE, kingdom=self.k)
		f2.save()

		self.e.text = "batard{{ septon|feminize }}, batard{{ cersei|feminize }}"
		self.e.save()

		pe = PendingEvent(
			event=self.e,
			kingdom=self.k,
			started=None
		)
		pe.save()
		pe.set_value("septon", f)
		pe.set_value("cersei", f2)

		pe.started = datetime.now()
		pe.save()

		self.assertEqual(pe.text, "batard, batarde")
Exemple #4
0
	def test_freeze_advanced(self):
		"""
		Test advanced freeze mechanism : pending_event_variable are restored (this is "second level restoration" since this Variable has nothing to do with the kingdom)
		"""

		from event.models import Event, PendingEvent
		e = Event(
			name="Event 1",
			slug="event_1",
			category=None,
			text="Event 1",
			on_fire=""
		)
		e.save()
		pe = PendingEvent(
			event=e,
			kingdom=self.k
		)
		pe.save()
		pe.set_value('foo', 'bar')
		pe.set_value('folk', self.f)


		freezed_pe_pk = pe.pk

		freeze = Freeze(kingdom=self.k)
		freeze.save()

		# Terminate PendingEvent
		pe.delete()

		# Unfreeze
		freeze.restore()

		# Check variable has been restored
		pe = PendingEvent.objects.get(pk=freezed_pe_pk)
		self.assertEqual(pe.get_value('foo'), 'bar')
		self.assertEqual(pe.get_value('folk'), self.f)
Exemple #5
0
	def test_next_event_slug(self):
		"""
		Tests we can create from event slug too.
		"""
		pe = PendingEvent(
			event=self.e,
			kingdom=self.k,
			started=None
		)
		pe.save()
		pe.set_value("valeur", 10)

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

		pe.next_event("event_2").start()

		pe2 = PendingEvent.objects.get(kingdom=self.k, event=e2)
		self.assertEqual(10, pe2.get_value("valeur"))
Exemple #6
0
	def test_next_event(self):
		"""
		Tests if the new event is created with the old context
		"""
		pe = PendingEvent(
			event=self.e,
			kingdom=self.k,
			started=None
		)
		pe.save()
		pe.set_value("valeur", 10)

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

		pe.next_event(e2).start()

		pe2 = PendingEvent.objects.get(kingdom=self.k, event=e2)
		self.assertEqual(10, pe2.get_value("valeur"))
Exemple #7
0
	def test_templates_and_folks_list_templatetags(self):
		"""
		Check folks_list template_tags.
		"""
		f = Folk(first_name="septon", kingdom=self.k)
		f.save()
		f2 = Folk(first_name="cersei", kingdom=self.k)
		f2.save()

		self.e.text = "{{ folks|folks_list:'short' }}"
		self.e.save()

		pe = PendingEvent(
			event=self.e,
			kingdom=self.k,
			started=None
		)
		pe.save()
		pe.set_value("folks", [f, f2])

		pe.started = datetime.now()
		pe.save()

		self.assertEqual(pe.text, "septon et cersei")