Exemplo n.º 1
0
def test_create_and_fetch():
    conn = connect()
    store = NoteStore(conn)
    note = Note(None, "title", "content")
    store.create(note)

    assert note.note_id is not None
    assert note.title == "title"
    assert note.content == "content"

    from_db = store.fetch(note.note_id)
    assert from_db.note_id == note.note_id
    assert from_db.title == note.title
    assert from_db.content == note.content
Exemplo n.º 2
0
def test_delete():
    conn = connect()
    store = NoteStore(conn)
    note = Note(None, "title", "content")
    store.create(note)

    assert store.fetch(note.note_id) is not None
    store.delete(note.note_id)

    assert store.fetch(note.note_id) is None
Exemplo n.º 3
0
def test_update():
    conn = connect()
    store = NoteStore(conn)

    note = Note(None, 'title', 'content')
    store.create(note)

    note.title = "Better Title"
    note.content = "Better Content"
    store.update(note)

    from_db = store.fetch(note.note_id)
    assert from_db.title == "Better Title"
    assert from_db.content == "Better Content"
Exemplo n.º 4
0
def test_fetch_all():
    conn = connect()
    store = NoteStore(conn)

    first = Note(None, "a", "ac")
    store.create(first)

    second = Note(None, "b", "bc")
    store.create(second)

    all_notes = store.fetch_all()
    assert len(all_notes) == 2
    assert all_notes[0].note_id == first.note_id
    assert all_notes[0].title == first.title
    assert all_notes[0].content == first.content

    assert all_notes[1].note_id == second.note_id
    assert all_notes[1].title == second.title
    assert all_notes[1].content == second.content
Exemplo n.º 5
0
def test_returns_none_when_no_note_was_found():
    conn = connect()
    store = NoteStore(conn)
    assert store.fetch(555) is None