1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
from django.test import TestCase
from mixer.backend.django import mixer
from notes.models import Note, Folder
from accounts.models import User
class FolderModelTest(TestCase):
def test_string_representation(self):
user = mixer.blend(User, username='tpynchon')
folder = Folder(created_by=user, name="My Folder")
self.assertEqual(str(folder), "My Folder")
class NoteModelTest(TestCase):
def setUp(self):
self.user = mixer.blend(User, username='test')
self.note = Note.objects.create(
created_by=self.user,
title="test 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.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))
|