from django.test import TestCase

from notes.models import Note
from user.models import User


class NoteTestCase(TestCase):

    def setUp(self):
        self.user = User.objects.create(username='test_user', password='<PASSWORD>')
        self.note = Note.objects.create(
            title='New TestNote',
            author=self.user,
            body_raw='Test text'
        )

    def test_slug(self):
        self.assertEqual(self.note.slug, 'new-testnote')

    def test_unique_slug(self):
        note_2 = Note.objects.create(title='New Test Note', author=self.user)
        self.assertNotEqual(self.note.slug, note_2.slug)

    def test_body_html(self):
        self.assertEqual(self.note.body_html, '<p>Test text</p>\n')

from django.test import TestCase

from notes.models import Note
from user.models import User


class NoteTestCase(TestCase):

    def setUp(self):
        self.user = User.objects.create(username='test_user', password='<PASSWORD>')
        self.note = Note.objects.create(
            title='New TestNote',
            author=self.user,
            body_raw='Test text'
        )

    def test_slug(self):
        self.assertEqual(self.note.slug, 'new-testnote')

    def test_unique_slug(self):
        note_2 = Note.objects.create(title='New Test Note', author=self.user)
        self.assertNotEqual(self.note.slug, note_2.slug)

    def test_body_html(self):
        self.assertEqual(self.note.body_html, '<p>Test text</p>\n')
