Пример #1
0
	def test_listing_returns_correct_html(self):
		cache = Geocache.objects.create()
		request = HttpRequest()
		response = listing(request, cache.id)
		expected_html = render_to_string(
			'listing.html',
			{'listing': listing}
		)
		self.assertIsNotNone(response.content.decode())
Пример #2
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())
Пример #3
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())