Make unit tests pass
This commit is contained in:
parent
3b407f393d
commit
9e85205b53
1 changed files with 15 additions and 9 deletions
|
|
@ -1,17 +1,14 @@
|
|||
import os
|
||||
|
||||
from django.test import TestCase
|
||||
from django.core.files import File
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from django.core.files import File
|
||||
from django.test import Client
|
||||
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from .models import Post, Collection
|
||||
from .models import Collection
|
||||
from .models import Post
|
||||
from ..circles.models import Circle
|
||||
|
||||
|
||||
# Create your tests here.
|
||||
|
|
@ -108,6 +105,7 @@ class PostViewsTests(TestCase):
|
|||
self.assertFalse(self.post.comments.all().exists())
|
||||
|
||||
def test_can_post_a_post(self):
|
||||
circ = Circle.objects.create(name="foobar", owner=self.user)
|
||||
c = Client()
|
||||
c.login(username="someone", password="secret")
|
||||
url = reverse("posts:post_create")
|
||||
|
|
@ -115,6 +113,14 @@ class PostViewsTests(TestCase):
|
|||
os.path.join(os.path.dirname(__file__), "test_data", "test_img.png"),
|
||||
mode="rb",
|
||||
) as f:
|
||||
c.post(url, {"title": "title", "body": "body", "img": File(f)})
|
||||
c.post(
|
||||
url,
|
||||
{
|
||||
"title": "title",
|
||||
"body": "body",
|
||||
"img": File(f),
|
||||
"circles": [circ.pk],
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(Post.objects.count(), 2)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue