示例#1
0
def local_store_keeps_separate_operations_for_different_arguments(pickle_dump, marshal_dump):
    changed_function = Mock(return_value=1)
    note_store = get_note_store()
    local_note_store = LocalNoteStore(note_store, changed_function)
    data_function = Mock()
    data_function.__name__ = 'data_function'

    local_note_store.get_if_changed(data_function, 1)
    local_note_store.get_if_changed(data_function, 2)

    assert_equal(data_function.call_count, 2)
示例#2
0
def local_store_wraps_edam_note_store(pickle_dump, marshal_dump):
    note_store = get_note_store()
    changed_function = Mock(return_value=1)
    local_note_store = LocalNoteStore(note_store, changed_function)

    local_note_store.listNotebooks()
    local_note_store.listNotebooks()
    
    assert_equal(note_store.listNotebooks.call_count, 1)
    changed_function.return_value = 2

    local_note_store.listNotebooks()
    local_note_store.listNotebooks()

    assert_equal(note_store.listNotebooks.call_count, 2)
示例#3
0
def local_store_only_updates_when_there_are_changes(pickle_dump, marshal_dump):
    changed_function = Mock(return_value=1)
    note_store = get_note_store()
    local_note_store = LocalNoteStore(note_store, changed_function)
    data_function = Mock()
    data_function.__name__ = 'data_function'

    local_note_store.get_if_changed(data_function)
    local_note_store.get_if_changed(data_function)

    assert_equal(data_function.call_count, 1)
    changed_function.return_value = 2

    local_note_store.get_if_changed(data_function)
    local_note_store.get_if_changed(data_function)

    assert_equal(data_function.call_count, 2)
示例#4
0
def local_store_persists_data(pickle_dump):
    note_store = get_note_store()
    note_store.listNotebooks.__name__ = 'listNotebooks'
    def listNotebooks(*args, **kwargs):
        return []
    note_store.listNotebooks.func_code = listNotebooks.func_code

    local_note_store = LocalNoteStore(note_store, Mock())
    local_note_store.listNotebooks()
    local_note_store = LocalNoteStore(note_store, Mock())
    local_note_store.listNotebooks()

    assert_equal(note_store.listNotebooks.call_count, 1)