Coverage for learning_logs/tests/test_models.py: 85.71%
24 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-12 08:03 -0700
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-12 08:03 -0700
1from django.contrib.auth import get_user_model 1a
2from django.test import TestCase 1a
4from ..models import Entry, Topic 1a
7class TopicModelTest(TestCase): 1a
8 def setUp(self): 1a
9 User = get_user_model() 1a
10 self.user = User.objects.create_user( 1a
11 username="kevin",
12 email="kevin@example.com",
13 password="T3stP@5s123",
14 )
15 self.topic = Topic.objects.create(owner=self.user, text="just a test") 1a
16 self.entry = Entry.objects.create(topic=self.topic, text="Entry text") 1a
17 self.long_entry = Entry.objects.create( 1a
18 topic=self.topic,
19 text="This is a long Entry text that should be concatenated.",
20 )
22 """ 1a
23 def test_topic_content(self):
24 topic = Topic.objects.get(id=1)
25 self.text = f"{topic.text}"
26 self.assertEqual(self.text, "just a test")
27 """
29 def test_topic___str__(self): 1a
30 self.assertEqual(str(self.topic), self.topic.text) 1a
32 def test_topic_get_absolute_url(self): 1a
33 assert self.topic.get_absolute_url() == f"/topics/{self.topic.id}/" 1a
35 """ 1a
36 def test_entry_content(self):
37 entry = Entry.objects.get(id=1)
38 self.text = f"{entry.text}"
39 self.assertEqual(self.text, "Entry text")
40 """
42 def test_entry__str__(self): 1a
43 if len(self.entry.text[:]) < 50: 43 ↛ 46line 43 didn't jump to line 46 because the condition on line 43 was always true1a
44 self.assertEqual(str(self.entry), self.entry.text) 1a
45 else:
46 self.assertEqual(str(self.entry), f"{self.entry.text[:50]} ... ")
48 def test_long_entry__str__(self): 1a
49 if len(self.long_entry.text[:]) < 50: 49 ↛ 50line 49 didn't jump to line 50 because the condition on line 49 was never true1a
50 self.assertEqual(str(self.long_entry), self.long_entry.text)
51 else:
52 self.assertEqual(str(self.long_entry), f"{self.long_entry.text[:50]}...") 1a