示例#1
0
    def test0010_cbrx_connection_open_valid(self):
        print "\ntest0010_cbrx_connection_open_valid ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)
        self.assertNotEqual(handle, "")
        self.assertNotEqual(handle, False)
        cbrxapi.cbrx_connection_close(handle)
示例#2
0
    def test007_cbrx_connection_open_device_twice(self):
        print "\ntest007_cbrx_connection_open_device_twice ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle1 = cbrxapi.cbrx_connection_open(device)
        self.assertNotEqual(handle1, "")
        self.assertNotEqual(handle1, False)
        handle2 = cbrxapi.cbrx_connection_open(device)
        self.assertNotEqual(handle2, "")
        self.assertNotEqual(handle2, False)

        cbrxapi.cbrx_connection_close(handle2)
        cbrxapi.cbrx_connection_close(handle1)
示例#3
0
    def test0041_cbrx_connection_set_invalid_tag(self):
        print "\ntest0041_cbrx_connection_set ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)

        gotException = False
        errorCode = 0
        result = ""

        try:
            result = cbrxapi.cbrx_connection_set(handle, "INVALID_TAG",
                                                 "INVALID")
        except jsonrpc.RPCFault as e:
            gotException = True
            errorCode = e.error_code

        print "Result: ",
        print result,
        print " "

        self.assertEqual(gotException, True)
        self.assertEqual(errorCode, CBRXAPI_ERRORCODE_ERRORSETTINGVALUE)
        self.assertEqual(result, "")

        result = cbrxapi.cbrx_connection_close(handle)
示例#4
0
    def test0030_cbrx_connection_get(self):
        print "\ntest0030_cbrx_connection_get ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)
        result = cbrxapi.cbrx_connection_get(handle, "nrOfPorts")
        self.assertNotEqual(result, 0)
        result = cbrxapi.cbrx_connection_close(handle)
示例#5
0
    def test005_cbrx_connection_close(self):
        print "\ntest005_cbrx_connection_close ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)

        result = cbrxapi.cbrx_connection_close(handle)
        self.assertEqual(result, True)
示例#6
0
    def test008_cbrx_connection_close_handle_twice(self):
        print "\ntest008_cbrx_connection_close_handle_twice ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle1 = cbrxapi.cbrx_connection_open(device)
        self.assertNotEqual(handle1, "")
        self.assertNotEqual(handle1, False)

        cbrxapi.cbrx_connection_close(handle1)

        try:
            cbrxapi.cbrx_connection_close(handle1)
        except jsonrpc.RPCFault as e:
            gotException = True
            errorCode = e.error_code

        self.assertEqual(gotException, True)
        self.assertEqual(errorCode, CBRXAPI_ERRORCODE_INVALIDHANDLE)
示例#7
0
    def test0020_cbrx_connection_getdictionary(self):
        print "\ntest0020_cbrx_connection_getdictionary ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)
        dictionary = cbrxapi.cbrx_connection_getdictionary(handle)
        self.assertNotEqual(dictionary, "")
        self.assertNotEqual(dictionary, False)

        handle = cbrxapi.cbrx_connection_close(handle)
示例#8
0
    def test0040_cbrx_connection_set(self):
        print "\ntest0040_cbrx_connection_set ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)
        result = cbrxapi.cbrx_connection_set(handle, "Port.3.mode", "c")

        print "\nResult: ",
        print result
        self.assertEqual(result, True)
        result = cbrxapi.cbrx_connection_close(handle)
示例#9
0
    def test0021_cbrx_connection_getdictionary_invalidhandle(self):
        print "\ntest0021_cbrx_connection_getdictionary_invalidhandle ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)

        badhandle = "INVALID"
        gotException = False
        errorCode = 0
        dictionary = ""

        try:
            dictionary = cbrxapi.cbrx_connection_getdictionary(badhandle)
        except jsonrpc.RPCFault as e:
            gotException = True
            errorCode = e.error_code

        self.assertEqual(gotException, True)
        self.assertEqual(errorCode, CBRXAPI_ERRORCODE_INVALIDHANDLE)
        self.assertEqual(dictionary, "")

        cbrxapi.cbrx_connection_close(handle)
示例#10
0
    def test0033_cbrx_connection_get_missing_tag(self):
        print "\ntest0032_cbrx_connection_get_missing_tag ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)
        gotException = False
        errorCode = 0
        result = ""

        try:
            result = cbrxapi.cbrx_connection_get(handle)
        except jsonrpc.RPCFault as e:
            gotException = True
            errorCode = e.error_code

        self.assertEqual(gotException, True)
        self.assertEqual(errorCode, JSONRPC_ERRORCODE_INVALIDPARAMETERS)
        self.assertEqual(result, "")

        result = cbrxapi.cbrx_connection_close(handle)
示例#11
0
    def test0031_cbrx_connection_get_invalid_tag(self):
        print "\ntest0031_cbrx_connection_get_invalid_tag ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)

        gotException = False
        errorCode = 0
        result = ""

        try:
            result = cbrxapi.cbrx_connection_get(handle, "INVALID")
        except jsonrpc.RPCFault as e:
            gotException = True
            errorCode = e.error_code

        self.assertEqual(gotException, True)
        self.assertEqual(errorCode, CBRXAPI_ERRORCODE_KEYNOTFOUND)
        self.assertEqual(result, "")

        result = cbrxapi.cbrx_connection_close(handle)
示例#12
0
    def test0034_cbrx_connection_get_invalid_handle(self):
        print "\ntest0034_cbrx_connection_get_invalid_handle ",
        result = cbrxapi.cbrx_discover("local")
        if result:
            device = result[0]

        handle = cbrxapi.cbrx_connection_open(device)

        badhandle = "INVALID"
        gotException = False
        errorCode = 0
        result = ""

        try:
            result = cbrxapi.cbrx_connection_get(badhandle, "nrOfPorts")
        except jsonrpc.RPCFault as e:
            gotException = True
            errorCode = e.error_code

        self.assertEqual(gotException, True)
        self.assertEqual(errorCode, CBRXAPI_ERRORCODE_INVALIDHANDLE)
        self.assertEqual(result, "")

        result = cbrxapi.cbrx_connection_close(handle)
import sys
from cbrxapi import cbrxapi

result = cbrxapi.cbrx_discover("local")
if result==False:
    print "No Cambrionix unit found."
    sys.exit(0)

unitId = result[0]
handle = cbrxapi.cbrx_connection_open(unitId)

for i in range(1, 17):
    serial = cbrxapi.cbrx_connection_get(handle, "Port." +  str(i) + ".SerialNumber")
    if serial != "" :
        output = str(i) + ":" + str(serial)
        print output

cbrxapi.cbrx_connection_close(handle)
示例#14
0
 def tearDown(self):
     cbrxapi.cbrx_connection_close(TestDictionary.handle)
示例#15
0
        self.assertEqual(value, False)

    def test_get_Profile_5_enabled(self):
        # Profile.5.enabled : False
        tag = "Profile.5.enabled"
        print tag
        value = cbrxapi.cbrx_connection_get(TestDictionary.handle, tag)
        print value
        self.assertEqual(value, False)

if __name__ == '__main__':

    # find first local cambrionix device
    result = cbrxapi.cbrx_discover("local")
    if result:
        TestDictionary.device = result[0]
    else:
        TestDictionary.device = False

    if not TestDictionary.device:
        print "No device found, cannot run test"
        sys.exit()

    TestDictionary.handle = cbrxapi.cbrx_connection_open(TestDictionary.device)
    cbrxapi.cbrx_connection_getdictionary(TestDictionary.handle)
    cbrxapi.cbrx_connection_close(TestDictionary.handle)

    print "Running tests"

    unittest.main()