def test_can_connect_to_db(): clear_expectations() db = Db(connection_context) db.connect() assert db.is_connected
def test_disconnection_calls_close(): clear_expectations() db = Db(connection_context) db.connect() db.disconnect() assert not db.is_connected
def test_disconnection_sets_store_to_null(): clear_expectations() db = Db(connection_context) db.connect() db.disconnect() assert not db.store
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