예제 #1
0
 def test_attributes(self):
     book = BookFactory()
     text = fake.paragraph()
     note = Note.create(text=text, book=book)
     assert note.text == text
     assert isinstance(note.date_created, dt.datetime)
     assert note.book == book
예제 #2
0
    def test_post_creates_note(self, wt):
        book = BookFactory()
        url = url_for('notes.NoteList:post')
        old_count = Note.query.count()
        text = '\n'.join(fake.paragraphs(5))
        res = wt.post_json(url, {'text': text, 'book_id': book.id})
        assert res.status_code == http.CREATED
        new_count = Note.query.count()
        assert new_count == old_count + 1

        latest = Note.get_latest()
        assert latest.text == text