예제 #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_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)