Esempio n. 1
0
def test_error_when_removing_from_different_instance():
    session1 = Session({"examples/1": {}})
    session2 = Session({})

    ex1 = session1.get(Example, 1)
    with pytest.raises(RuntimeError):
        session2.remove(ex1)
Esempio n. 2
0
def test_remove_is_idempotent():
    data = {"examples/1": {"name": "Paula"}}
    session = Session(data)

    ex1 = session.get(Example, 1)
    session.remove(ex1)
    session.remove(ex1)
    session.flush()
Esempio n. 3
0
def test_get_then_remove_entity():
    data = {"examples/1": {"name": "Paula"}}
    session = Session(data)

    ex1 = session.get(Example, 1)
    session.remove(ex1)
    session.flush()

    assert data == {}
Esempio n. 4
0
def test_add_then_remove_entity_has_no_effect():
    data = {}
    session = Session(data)

    ex1 = Example(pk=1, name="Horse")
    session.add(ex1)
    session.remove(ex1)
    session.flush()

    assert data == {}