Permalink
Browse files

Added version testcase. Added admin test. Modified a few model fields…

… to allow creation of the snippet without a lot of fields
  • Loading branch information...
xarg committed May 24, 2011
1 parent d5cf016 commit d2a115a2e8dcc0049d123f0431fd6d01ee615253
Showing with 31 additions and 6 deletions.
  1. +4 −3 snippets/models.py
  2. +27 −3 snippets/tests.py
View
@@ -49,14 +49,15 @@ class Snippet(models.Model):
body = models.TextField(help_text="Snippet code goes here")
created_date = models.DateTimeField(auto_now_add=True)
updated_date = models.DateTimeField(auto_now=True)
- status = models.CharField(max_length=50, default='published',
+ status = models.CharField(blank=True, max_length=50, default='published',
choices=STATUS_CHOICES)
- privacy = models.CharField(max_length=50, default='public',
+ privacy = models.CharField(blank=True, max_length=50, default='public',
choices=PRIVACY_CHOICES)
tags = TaggableManager(blank=True)
# Used to provide some kind of stats
- via = models.CharField(max_length=50, default='web', choices=ADDED_VIA)
+ via = models.CharField(max_length=50, default='web', blank=True,
+ choices=ADDED_VIA)
def __unicode__(self):
return self.title
View
@@ -92,6 +92,20 @@ def test_update_snippet(self):
updated_snippet = Snippet.objects.get(pk=self.snippet_text.pk)
self.assertEqual(updated_snippet.title, title_text)
+ def test_create_admin(self):
+ """ Add a snippet from administration section """
+ title = 'a snippet'
+ body = 'body'
+ self.client.login(username='superuser', password='password')
+ self.client.post('/admin/snippets/snippet/add/',
+ {'title': title, 'body': body})
+ snippet = Snippet.objects.get(title=title)
+ self.assertEqual(snippet.body, body)
+
+ def test_update_notification(self):
+ """ Create a user and then make him follow another user.
+ Update an existing snippet and check if the notification was sent. """
+
def test_preview_snippet(self):
""" When the user click the preview button an ajax request will be called
which returns a html content of the snippet"""
@@ -105,9 +119,6 @@ def test_preview_snippet(self):
self.assertEqual(response.status_code, 200)
self.assertTrue('This is a text snippet' in response.content)
- def test_history(self):
- """Check snippet versions"""
-
def test_search(self):
""" Test the search results """
@@ -120,6 +131,19 @@ def test_download(self):
def test_delete(self):
"""Make sure it redirects properly"""
+class VersioningTestCase(SnippetsTestCase):
+ """ Versioning of snippets support. Check if diff works properly """
+
+ def test_create(self):
+ """ Update a snippet and check if the version is there"""
+
+ def test_view(self):
+ """ View a specific version """
+
+ def test_diff(self):
+ """ Update the same snippet the second time and check the diff
+ output"""
+
class CommentsTestCase(SnippetsTestCase):
""" Testing comments functionality """

0 comments on commit d2a115a

Please sign in to comment.