Пример #1
0
def test_can_connect_to_db():
    clear_expectations()

    db = Db(connection_context)

    db.connect()
    assert db.is_connected
Пример #2
0
def test_disconnection_calls_close():
    clear_expectations()

    db = Db(connection_context)

    db.connect()
    db.disconnect()
    assert not db.is_connected
Пример #3
0
def test_disconnection_sets_store_to_null():
    clear_expectations()

    db = Db(connection_context)

    db.connect()
    db.disconnect()
    assert not db.store
Пример #4
0
def test_connecting_twice_raises():
    clear_expectations()

    db = Db(connection_context)

    db.connect()

    try:
        db.connect()
    except RuntimeError, err:
        assert str(err) == "You have to disconnect before connecting again"
        return