diff options
Diffstat (limited to 'apps/notes/tests/test_models.py')
-rw-r--r-- | apps/notes/tests/test_models.py | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/apps/notes/tests/test_models.py b/apps/notes/tests/test_models.py index e6cdb6a..ddb731e 100644 --- a/apps/notes/tests/test_models.py +++ b/apps/notes/tests/test_models.py @@ -14,17 +14,31 @@ class FolderModelTest(TestCase): class NoteModelTest(TestCase): - - def test_string_representation(self): - user = mixer.blend(User, username='test') - note = Note( - created_by=user, + def setUp(self): + self.user = mixer.blend(User, username='test') + self.note = Note.objects.create( + created_by=self.user, title="test note", - body_markdown="the body of the note", + body="the body of the note", + url="https://luxagraf.net/", + tags="mine,cool site" + ) + self.note.save() + self.note_no_title = Note.objects.create( + created_by=self.user, + body="the body of the note", url="https://luxagraf.net/", tags="mine,cool site" - ) - self.assertEqual(str(note), "test note") - self.assertEqual(str(note.body_markdown), "the body of the note") - self.assertEqual(str(note.url), "https://luxagraf.net/") - self.assertEqual(str(note.tags), "mine,cool site") + ) + self.note_no_title.save() + + def test_string_representation(self): + self.assertEqual(str(self.note), "test note") + self.assertEqual(str(self.note.body), "the body of the note") + self.assertEqual(str(self.note.url), "https://luxagraf.net/") + self.assertEqual(str(self.note.tags), "mine,cool site") + # titleless note gets date + self.assertEqual(str(self.note_no_title), str(self.note_no_title.date_created)) + + def test_get_absolute_url(self): + self.assertEqual(str(self.note.get_absolute_url()), "/notes/%s/" % (self.note.id)) |