def test_command(self):

        connection = pyorient.OrientSocket( "localhost", 2424 )

        factory = pyorient.OrientDB(connection)

        session_id = ( factory.get_message(pyorient.CONNECT) ).prepare( ("root", "root") )\
            .send().fetch_response()

        db_name = "tmp_test1"

        try:
            # at the end drop the test database
            ( factory.get_message(pyorient.DB_DROP) ).prepare([db_name, pyorient.STORAGE_TYPE_MEMORY]) \
                .send().fetch_response()

        except pyorient.PyOrientCommandException as e:
            print(str(e))
        finally:
            ( factory.get_message(pyorient.DB_CREATE) ).prepare(
                (db_name, pyorient.DB_TYPE_GRAPH, pyorient.STORAGE_TYPE_MEMORY)
            ).send().fetch_response()

        # open as serialize2binary
        msg = factory.get_message(pyorient.DB_OPEN)
        cluster_info = msg.prepare(
            (db_name, "admin", "admin", pyorient.DB_TYPE_DOCUMENT, "", pyorient.OrientSerialization.CSV)
        ).send().fetch_response()

        # ##################

        create_class = factory.get_message(pyorient.COMMAND)
        ins_msg1 = factory.get_message(pyorient.COMMAND)
        ins_msg2 = factory.get_message(pyorient.COMMAND)
        ins_msg3 = factory.get_message(pyorient.COMMAND)
        ins_msg4 = factory.get_message(pyorient.COMMAND)
        upd_msg5 = factory.get_message(pyorient.RECORD_UPDATE)

        req_msg = factory.get_message(pyorient.COMMAND)

        create_class.prepare( ( pyorient.QUERY_CMD, "create class c_test extends V" ) )
        ins_msg1.prepare( ( pyorient.QUERY_CMD, "insert into c_test ( Band, Song ) values( 'AC/DC', 'Hells Bells' )") )
        ins_msg2.prepare( ( pyorient.QUERY_CMD, "insert into c_test ( Band, Song ) values( 'AC/DC', 'Who Made Who' )") )
        ins_msg3.prepare( ( pyorient.QUERY_CMD, "insert into c_test ( Band, Song ) values( 'AC/DC', 'T.N.T.' )") )
        ins_msg4.prepare( ( pyorient.QUERY_CMD, "insert into c_test ( Band, Song ) values( 'AC/DC', 'High Voltage' )") )


        cluster = create_class.send().fetch_response()
        rec1 = ins_msg1.send().fetch_response()
        rec2 = ins_msg2.send().fetch_response()
        rec3 = ins_msg3.send().fetch_response()
        rec4 = ins_msg4.send().fetch_response()

        rec1 = rec1[0]
        upd_res = upd_msg5.prepare( ( rec1._rid, rec1._rid, { 'Band': 'Metallica', 'Song': 'One' } ) )\
            .send().fetch_response()

        res = req_msg.prepare( [ pyorient.QUERY_SYNC, "select from c_test" ] ).send().fetch_response()

        assert isinstance(cluster, list)
        assert rec1._rid == res[0]._rid
        assert rec1._version != res[0]._version
        assert res[0]._version == upd_res[0]._version

        assert len(res) == 4
        assert res[0]._rid == '#11:0'
        assert res[0].Band == 'Metallica'
        assert res[0].Song == 'One'

        assert res[3].Song == 'High Voltage'

        # for x in res:
        #     print("############"
        #     print("%r" % x._rid
        #     print("%r" % x._class
        #     print("%r" % x._version
        #     print("%r" % x.Band
        #     print("%r" % x.Song


        # classes are allowed in record create/update/load
        rec = { '@c_test': { 'alloggio': 'casa', 'lavoro': 'ufficio', 'vacanza': 'mare' } }
        rec_position = ( factory.get_message(pyorient.RECORD_CREATE) )\
            .prepare( ( cluster[0], rec ) )\
            .send().fetch_response()

        print("New Rec Position: %s" % rec_position._rid)
        assert rec_position._rid is not None

        rec = { '@c_test': { 'alloggio': 'albergo', 'lavoro': 'ufficio', 'vacanza': 'montagna' } }
        update_success = ( factory.get_message(pyorient.RECORD_UPDATE) )\
            .prepare( ( rec_position._rid, rec_position._rid, rec ) )\
            .send().fetch_response()


        req_msg = factory.get_message(pyorient.RECORD_LOAD)
        res = req_msg.prepare( [ rec_position._rid, "*:-1" ] ) \
            .send().fetch_response()

        # print(res)
        # print(res._rid)
        # print(res._class)
        # print(res._version)
        # print(res.alloggio)
        # print(res.lavoro)
        # print(res.vacanza)

        assert res._rid == "#11:4"
        assert res._class == "c_test"
        assert res.alloggio == 'albergo'
        assert not hasattr( res, 'Band')
        assert not hasattr( res, 'Song')

        # print(""
        # # at the end drop the test database
        # ( DbDropMessage( connection ) ).prepare([db_name, STORAGE_TYPE_MEMORY]) \
        #     .send().fetch_response()


# x = CommandTestCase('test_command').run()
dataset/ETHPy150Open mogui/pyorient/tests/test_Factory_and_usage.py/CommandTestCase.test_command/original