Esempio n. 1
0
def test_store_create_item(monkeypatch):
    monkeypatch.setattr(MemoryStore, '_load_data', mock_load_data)
    store = MemoryStore('dir')
    collection = 'food'
    item_id = 'Steak'
    params = {'id': item_id, 'Price': '$10.00'}

    # Item is not in the collection
    assert item_id not in store.get_collection(collection)

    # Item is present after creation
    store.create_item(collection, params)
    assert store.get_item(collection, item_id) == params
Esempio n. 2
0
def test_store_delete_item(monkeypatch):
    monkeypatch.setattr(MemoryStore, '_load_data', mock_load_data)
    store = MemoryStore('dir')
    collection_id = 'food'
    item_id = 'Steak'
    params = {'id': item_id, 'Price': '$10.00'}

    # Newly created item is present in collection
    store.create_item(collection_id, params)
    assert item_id in store.get_collection(collection_id)

    # After deleting, no longer there
    store.delete_item(collection_id, item_id)
    assert item_id not in store.get_collection(collection_id)

    # Deleting the same item again returns none
    assert store.delete_item(collection_id, item_id) is None