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_drop_without_connect(self): connection = OrientSocket("localhost", 2424) with self.assertRaises(PyOrientException): ( DbDropMessage( connection ) ).prepare(["test"]) \ .send().fetch_response()