def notes(db_session, test_user): other_user = User(email='*****@*****.**', full_name='Testy McTestface') db_session.add(other_user) db_session.commit() content = 'This is not your note' return ( [Note.create(content='*foo*', author=test_user) for i in range(3)] + [Note.create(content=content, author=other_user) for i in range(3)])
def make_note(data): content, tags = data note = Note.create(content=content, author=test_user) for tag in tags: note.add_tag(tag) return note
def it_strips_html_tags_from_the_user_input(self, db_session, test_user): note = Note.create('<script>alert("bad things")</script>', test_user) assert note.content == 'alert("bad things")' note.update('<form action="evil.com/phish"><input name="cc"></form>') assert note.content == '' note.update('<p style="color: pink">woo!</p>') assert note.content == 'woo!'
def it_stores_the_previous_version(self, db_session, test_user): note = Note.create('Test note', test_user) assert len(note.history) == 0 note.update('Test note edited') assert len(note.history) == 1 assert note.history[0].content == 'Test note' assert note.history[0].version == 1
def add(): content = request.form.get('content', '').strip() tags = request.form.get('tags', '').split(',') if content: note = Note.create(content=content, author=current_user) for tag in tags: note.add_tag(tag.strip()) return redirect(url_for('.list'))
def it_can_be_reverted_to_a_previous_version(self, db_session, test_user): note = Note.create('Test note', test_user) note.update('Test note edited') note.update('Test note edited again') assert len(note.history) == 2 assert note.history[0].version == 0 assert note.history[1].version == 1 note.revert() assert len(note.history) == 3 assert note.content == 'Test note edited' note.revert(version=2) assert len(note.history) == 4 assert note.content == 'Test note edited again'
def example_note(db_session, test_user): note = Note.create('Original content', test_user) return note
def updated_note(db_session): note = Note.create('Original text') note.update('Updated text') return note
def updated_note(db_session, test_user): note = Note.create('Original content', test_user) note.update('Updated content') return note
def tagged_note(db_session, test_user): note = Note.create(content='A tagged note', author=test_user) note.add_tag('foo') note.add_tag('bar') return note
def some_notes(db_session, test_user): _notes = [ 'foo', 'read', 'reader', 'baz and bar', 'a bar', 'bar baz bar baz'] return [Note.create(content=note, author=test_user) for note in _notes]
def some_notes(db_session, test_user): _notes = [ 'foo', 'read', 'reader', 'baz and bar', 'a bar', 'bar baz bar baz' ] return [Note.create(content=note, author=test_user) for note in _notes]
def it_must_have_an_author(self, db_session): with pytest.raises(TypeError): Note.create('Test note')