mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 20:06:35 +11:00
Added tests to make sure content is saved with leading whitespaces in the db.
This commit is contained in:
parent
6255885bea
commit
b1b7aa51a4
3 changed files with 21 additions and 5 deletions
|
@ -239,3 +239,13 @@ class SnippetAPITestCase(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(Snippet.objects.count(), 1)
|
||||
self.assertEqual(Snippet.objects.all()[0].lexer, 'php')
|
||||
|
||||
def test_leading_white_is_retained(self):
|
||||
"""
|
||||
Leading Whitespace is retained in the db.
|
||||
"""
|
||||
content = u' one\n two\n three\n four'
|
||||
self.client.post(self.api_url, {'content': content})
|
||||
self.assertEqual(Snippet.objects.all()[0].content, content)
|
||||
|
||||
|
||||
|
|
|
@ -401,3 +401,12 @@ class SnippetTestCase(TestCase):
|
|||
slug_list = Snippet.objects.values_list(
|
||||
'secret_id', flat=True).order_by('published')
|
||||
self.assertEqual(len(set(slug_list)), 100)
|
||||
|
||||
def test_leading_white_is_retained_in_db(self):
|
||||
"""
|
||||
Leading Whitespace is retained in the db.
|
||||
"""
|
||||
content = u' one\n two\n three\n four'
|
||||
data = self.valid_form_data(content=content)
|
||||
self.client.post(self.new_url, data, follow=True)
|
||||
self.assertEqual(Snippet.objects.all()[0].content, content)
|
||||
|
|
|
@ -6,15 +6,13 @@ import json
|
|||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.urls import reverse
|
||||
from django.db.models import Count
|
||||
from django.http import (Http404, HttpResponse, HttpResponseBadRequest,
|
||||
HttpResponseRedirect)
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.defaults import page_not_found as django_page_not_found, \
|
||||
server_error as django_server_error
|
||||
from django.views.generic import FormView
|
||||
|
@ -112,7 +110,6 @@ class SnippetDetailView(SnippetView, DetailView):
|
|||
def highlight_snippet(self):
|
||||
snippet = self.get_object()
|
||||
h = pygmentize(snippet.content, snippet.lexer)
|
||||
h = h.replace(u' ', u' ')
|
||||
h = h.replace(u'\t', ' ')
|
||||
return h
|
||||
|
||||
|
|
Loading…
Reference in a new issue