def test_db_exists(self): connection = OrientSocket("localhost", 2424) msg = ConnectMessage(connection) print("%r" % msg.get_protocol()) assert msg.get_protocol() != -1 session_id = msg.prepare( ("admin", "admin") )\ .send().fetch_response() print("Sid: %s" % session_id) assert session_id == connection.session_id assert session_id != -1 db_name = "GratefulDeadConcerts" # params = ( db_name, STORAGE_TYPE_MEMORY ) params = (db_name, STORAGE_TYPE_PLOCAL) msg = DbExistsMessage(connection) exists = msg.prepare(params).send().fetch_response() assert exists is True msg.close() print("%r" % exists)
def test_db_create_with_drop(self): connection = OrientSocket("localhost", 2424) conn_msg = ConnectMessage(connection) print("Protocol: %r" % conn_msg.get_protocol()) assert connection.protocol != -1 session_id = conn_msg.prepare( ("admin", "admin") ) \ .send().fetch_response() print("Sid: %s" % session_id) assert session_id == connection.session_id assert session_id != -1 # ################## db_name = "my_little_test" msg = DbExistsMessage(connection) exists = msg.prepare([db_name]).send().fetch_response() print("Before %r" % exists) assert exists is True # should happen every time because of latest test if exists is True: ( DbDropMessage( connection ) ).prepare([db_name]) \ .send().fetch_response() print("Creation again") try: (DbCreateMessage(connection)).prepare( (db_name, DB_TYPE_DOCUMENT, STORAGE_TYPE_PLOCAL)).send().fetch_response() assert True except PyOrientCommandException as e: print(str(e)) assert False # No expected Exception msg = DbExistsMessage(connection) exists = msg.prepare([db_name]).send().fetch_response() assert exists is True # at the end drop the test database ( DbDropMessage( connection ) ).prepare([db_name]) \ .send().fetch_response() msg.close() print("After %r" % exists)
def test_db_create_with_drop(self): connection = OrientSocket( "localhost", 2424 ) conn_msg = ConnectMessage( connection ) print("Protocol: %r" % conn_msg.get_protocol()) assert connection.protocol != -1 session_id = conn_msg.prepare( ("admin", "admin") ) \ .send().fetch_response() print("Sid: %s" % session_id) assert session_id == connection.session_id assert session_id != -1 # ################## db_name = "my_little_test" msg = DbExistsMessage( connection ) exists = msg.prepare( [db_name] ).send().fetch_response() print("Before %r" % exists) assert exists is True # should happen every time because of latest test if exists is True: ( DbDropMessage( connection ) ).prepare([db_name]) \ .send().fetch_response() print("Creation again") try: ( DbCreateMessage( connection ) ).prepare( (db_name, DB_TYPE_DOCUMENT, STORAGE_TYPE_PLOCAL) ).send().fetch_response() assert True except PyOrientCommandException as e: print(e.message) assert False # No expected Exception msg = DbExistsMessage( connection ) exists = msg.prepare( [db_name] ).send().fetch_response() assert exists is True # at the end drop the test database ( DbDropMessage( connection ) ).prepare([db_name]) \ .send().fetch_response() msg.close() print("After %r" % exists)
def test_db_create_with_connect(self): connection = OrientSocket("localhost", 2424) conn_msg = ConnectMessage(connection) print("Protocol: %r" % conn_msg.get_protocol()) session_id = conn_msg.prepare(("root", "root")) \ .send().fetch_response() print("Sid: %s" % session_id) assert session_id == connection.session_id assert session_id != -1 # ################## db_name = "my_little_test" response = '' try: (DbCreateMessage(connection)).prepare( (db_name, DB_TYPE_DOCUMENT, STORAGE_TYPE_PLOCAL) ).send().fetch_response() except PyOrientDatabaseException as e: assert True print(str(e)) except Exception as e: print(str(e)) assert False print("Creation: %r" % response) assert len(response) == 0 msg = DbExistsMessage(connection) msg.prepare((db_name, STORAGE_TYPE_PLOCAL)) # msg.prepare( [db_name] ) exists = msg.send().fetch_response() assert exists is True msg.close() print("%r" % exists)
def test_db_create_with_connect(self): connection = OrientSocket( "localhost", 2424 ) conn_msg = ConnectMessage( connection ) print("Protocol: %r" % conn_msg.get_protocol()) session_id = conn_msg.prepare( ("root", "root") )\ .send().fetch_response() print("Sid: %s" % session_id) assert session_id == connection.session_id assert session_id != -1 # ################## db_name = "my_little_test" response = '' try: ( DbCreateMessage( connection ) ).prepare( (db_name, DB_TYPE_DOCUMENT, STORAGE_TYPE_PLOCAL) ).send().fetch_response() except PyOrientDatabaseException as e: assert True print(str(e)) except Exception as e: print(str(e)) assert False print("Creation: %r" % response) assert len(response) is 0 msg = DbExistsMessage( connection ) msg.prepare( (db_name, STORAGE_TYPE_PLOCAL) ) # msg.prepare( [db_name] ) exists = msg.send().fetch_response() assert exists is True msg.close() print("%r" % exists)