Coverage for posts/tests/test_models.py: 100.00%

11 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-02 19:56 -0700

1from datetime import datetime as dt 

2 

3import pytest 

4 

5pytestmark = pytest.mark.django_db 

6 

7 

8def test_post___str__(post): 

9 assert post.__str__() == post.title 1b

10 assert str(post) == post.title 1b

11 

12 

13def test_post_get_absolute_url(post): 

14 slug_time = dt.now().strftime("%Y/%-m/%-d") 1c

15 assert post.get_absolute_url() == f"/posts/{slug_time}/{post.slug}/" 1c

16 

17 

18def test_comment__str__(comment): 

19 assert comment.__str__() == f"Comment by {comment.name} on {comment.post}" 1d