示例#1
0
文件: unit.py 项目: Neamar/kingdoms
	def test_avatar_image_child(self):
		"""
		Verify the good image is returned
		"""

		a = Avatar(
			adult_threshold=20,
			old_threshold=50,
			child=File(open(__file__), 'child'),
		)
		a.save()

		# Child image, no matter what.
		self.assertEqual(a.image(1), a.child.url)
		self.assertEqual(a.image(18), a.child.url)
		self.assertEqual(a.image(100), a.child.url)
示例#2
0
文件: unit.py 项目: Neamar/kingdoms
	def test_avatar_image_adult(self):
		"""
		Verify the good image is returned, depending on the age
		"""

		a = Avatar(
			adult_threshold=20,
			old_threshold=50,
			adult=File(open(__file__), 'adult'),
			old=File(open(__file__), 'old'),
		)
		a.save()

		# Age between adult_threshold and old_threshold: adult
		self.assertEqual(a.image(25), a.adult.url)
		# Age after old_threshold
		self.assertEqual(a.image(55), a.old.url)
		# Age lower than adult_threshold: adult anyway
		self.assertEqual(a.image(0), a.adult.url)