Skip to content

Commit

Permalink
Fixes unique error with accounts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
algosuna committed Jul 26, 2016
1 parent 4dc54fc commit 9130d81
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
11 changes: 6 additions & 5 deletions djangomx/accounts/tests.py
Expand Up @@ -4,7 +4,8 @@
from django_gravatar.helpers import has_gravatar
from model_mommy import mommy

from blog.models import Post
from blog.mommy_recipes import unique_post

from .models import Profile


Expand Down Expand Up @@ -38,10 +39,10 @@ class ProfileViewTestCase(TestCase):
def setUp(self):
self.user = mommy.make(User, username='test', email='me@netoxico.com')
self.profile = mommy.make(Profile, user=self.user)
self.post1 = mommy.make(Post, author=self.user)
self.post2 = mommy.make(Post, author=self.user)
self.post3 = mommy.make(Post, author=self.user)
self.post4 = mommy.make(Post, author=self.user, is_active=False)
self.post1 = unique_post.make(author=self.user)
self.post2 = unique_post.make(author=self.user)
self.post3 = unique_post.make(author=self.user)
self.post4 = unique_post.make(author=self.user, is_active=False)

def test_get_profile(self):
response = self.client.get(self.profile.get_absolute_url())
Expand Down
18 changes: 18 additions & 0 deletions djangomx/blog/mommy_recipes.py
@@ -0,0 +1,18 @@
from itertools import cycle

from model_mommy.recipe import Recipe

from .models import Post


POST_TITLES = [
'Bacon ipsum dolor amet',
'Turducken ham kevin',
'Beef shoulder meatloaf boudin',
'Ribeye kielbasa fatback shankle',
]

unique_post = Recipe(
Post,
title=cycle(POST_TITLES),
)

0 comments on commit 9130d81

Please sign in to comment.