Skip to content

Commit

Permalink
Fixed Unique constraint error
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaditcuy committed Apr 5, 2023
1 parent 110c94c commit 7855611
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/blog/test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class BlogModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create(username='testuser', password='password')
BlogAuthor.objects.filter(user=self.user).delete()
self.author = BlogAuthor.objects.create(user=self.user, bio='test bio')
self.blog = Blog.objects.create(title='test title', content='test content', author=self.author)

Expand Down Expand Up @@ -40,6 +41,7 @@ def test_blog_like_count(self):
class BlogAuthorModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create(username='testuser', password='password')
BlogAuthor.objects.filter(user=self.user).delete()
self.author = BlogAuthor.objects.create(user=self.user, bio='test bio')

def test_author_str(self):
Expand All @@ -52,6 +54,7 @@ def test_author_absolute_url(self):
class BlogCommentModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create(username='testuser', password='password')
BlogAuthor.objects.filter(user=self.user).delete()
self.author = BlogAuthor.objects.create(user=self.user, bio='test bio')
self.blog = Blog.objects.create(title='test title', content='test content', author=self.author)
self.comment = BlogComment.objects.create(blog=self.blog, content='test comment', commenter=self.user)
Expand All @@ -67,6 +70,7 @@ def test_comment_ordering(self):
class BlogViewModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create(username='testuser', password='password')
BlogAuthor.objects.filter(user=self.user).delete()
self.author = BlogAuthor.objects.create(user=self.user, bio='test bio')
self.blog = Blog.objects.create(title='test title', content='test content', author=self.author)

Expand All @@ -78,6 +82,7 @@ def test_view_str(self):
class BlogLikeModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create(username='testuser', password='password')
BlogAuthor.objects.filter(user=self.user).delete()
self.author = BlogAuthor.objects.create(user=self.user, bio='test bio')
self.blog = Blog.objects.create(title='test title', content='test content', author=self.author)

Expand Down

0 comments on commit 7855611

Please sign in to comment.