示例#1
0
def save(request):
	if request.method == 'POST':
		post = request.POST
		title = post['title']
		code = Code(title=post['title'], language=post['language'], code=post['code'])
		code.save()
	return HttpResponseRedirect(reverse('show', args=(code.slug,)))
示例#2
0
	def test_slugfy(self):
		code = Code(title='title test',language='language',code='code')
		code.save()
		self.assertTrue(code.slug == 'title-test')
示例#3
0
	def test_should_have_a_slug(self):
		code = Code(title='test slug', language='python', code='code')
		code.save()
		self.assertTrue(code.slug == 'test-slug')
示例#4
0
	def test_show_code(self):
		code = Code(title='show test', language='python', code='code show test')
		code.save()
		response = self.client.get(reverse('show', args=(code.slug,)))
		self.assertTrue(response.status_code == 200)
		self.assertContains(response, code.title)