Esempio n. 1
0
	def test_listing_page_can_save_a_POST_request(self):
		cache = Geocache.objects.create()
		cache.save()
		old_log = Log(text='An old log', geocache=cache)
		old_log.save()
		request = HttpRequest()
		request.method = 'POST'
		request.POST['log_text'] = 'A new log'

		response = listing(request, cache.id)
		
		self.assertEqual(Log.objects.count(), 2)

		self.assertIn('A new log', response.content.decode())
		self.assertIn('An old log', response.content.decode())
Esempio n. 2
0
	def test_geocache_and_log_relationship(self):
		g = Geocache()
		g.save()
		log = Log(id=None, text="test text", geocache=g)
		log.save()
		self.assertEqual(log.text, "test text")
		log2 = Log(id=None, text="test text", geocache=g)
		log2.save()
		saved_logs = Log.objects.all()
		self.assertEqual(saved_logs.count(), 2)
Esempio n. 3
0
	def test_all_previous_logs_are_shown(self):
		g = Geocache()
		g.save()
		first_log = Log(id=None, text="Test for first log", geocache=g)
		first_log.save()
		second_log = Log(id=None, text="Test for second log", geocache=g)
		second_log.save()
		request = HttpRequest()
		
		response = listing(request, g.id)

		self.assertIn("Test for first log", response.content.decode())
		self.assertIn("Test for second log", response.content.decode())