Beispiel #1
0
    def test_adjust_for_search(self):
        expected = "244"
        actual = VistaUtils.adjust_for_search("245")
        self.assertEqual(expected, actual)

        expected = "Snurc~"
        actual = VistaUtils.adjust_for_search("Snurd")
        self.assertEqual(expected, actual)
Beispiel #2
0
    def test_prepend_count(self):
        expected = "\x0aSomeString"
        actual = VistaUtils.prepend_count("SomeString")
        self.assertEqual(expected, actual)

        expected = "\x0aDDR LISTER"
        actual = VistaUtils.prepend_count("DDR LISTER")
        self.assertEqual(expected, actual)
    def test_prepend_count(self):
        expected = "\x0aSomeString"
        actual = VistaUtils.prepend_count("SomeString")
        self.assertEqual(expected, actual)

        expected = "\x0aDDR LISTER"
        actual = VistaUtils.prepend_count("DDR LISTER")
        self.assertEqual(expected, actual)
    def test_adjust_for_search(self):
        expected = "244"
        actual = VistaUtils.adjust_for_search("245")
        self.assertEqual(expected, actual)

        expected = "Snurc~"
        actual = VistaUtils.adjust_for_search("Snurd")
        self.assertEqual(expected, actual)
Beispiel #5
0
    def list_to_string(param_list):
        if not len(param_list):
            return VistaUtils.str_pack('', RpcParameter.COUNT_WIDTH) + 'f'

        param_string = ""
        for param in param_list:
            if param[1] == "":
                param[1] = "\x01"
            param_string += VistaUtils.str_pack(param[0], RpcParameter.COUNT_WIDTH) + \
                            VistaUtils.str_pack(param[1], RpcParameter.COUNT_WIDTH) + 't'
        return param_string[0:-1] + 'f'
Beispiel #6
0
    def list_to_string(param_list):
        if not len(param_list):
            return VistaUtils.str_pack('', RpcParameter.COUNT_WIDTH) + 'f'

        param_string = ""
        for param in param_list:
            if param[1] == "":
                param[1] = "\x01"
            param_string += VistaUtils.str_pack(param[0], RpcParameter.COUNT_WIDTH) + \
                            VistaUtils.str_pack(param[1], RpcParameter.COUNT_WIDTH) + 't'
        return param_string[0:-1] + 'f'
Beispiel #7
0
 def prepare_param_str(params):
     param_str = '5'
     if params:
         for param in params:
             if param.type == RpcParameter.LITERAL:
                 param_str += '0' + VistaUtils.str_pack(param.value, VistaRpc.COUNT_WIDTH) + 'f'
             elif param.type == RpcParameter.REFERENCE:
                 param_str += '1' + VistaUtils.str_pack(param.value, VistaRpc.COUNT_WIDTH) + 'f'
             elif param.type == RpcParameter.LIST:
                 param_str += '2' + RpcParameter.list_to_string(param.value)
             else:
                 raise VistaException('Invalid param type')
     if param_str == '5' : param_str += '4f'
     return param_str
Beispiel #8
0
    def __prepare_param_list(self):
        if not getattr(self, 'file', None):
            raise VistaException('VistaSelect must specify a file')
        self.param_list = [('"FILE"', self.file)]

        if getattr(self, 'iens', None):
            self.param_list += [('"IENS"', self.iens)]

        self.param_list += [('"FIELDS"', getattr(self, 'fields', '@'))]

        self.param_list += [('"FLAGS"', getattr(self, 'flags', 'IP'))]

        if getattr(self, 'number', None):
            self.param_list += [('"MAX"', str(self.number))]

        if getattr(self, 'frum', None):
            self.param_list += [('"FROM"', VistaUtils.adjust_for_search(self.frum))]

        if getattr(self, 'part', None):
            self.param_list += [('"PART"', self.part)]

        self.param_list += [('"XREF"', getattr(self, 'index', '#'))]

        if getattr(self, 'screen', None):
            self.param_list += [('"SCREEN"', self.screen)]

        if getattr(self, 'identifier', None):
            self.param_list += [('"ID"', self.identifier)]

        return self.param_list
Beispiel #9
0
 def prepare_param_str(params):
     param_str = '5'
     if params:
         for param in params:
             if param.type == RpcParameter.LITERAL:
                 param_str += '0' + VistaUtils.str_pack(
                     param.value, VistaRpc.COUNT_WIDTH) + 'f'
             elif param.type == RpcParameter.REFERENCE:
                 param_str += '1' + VistaUtils.str_pack(
                     param.value, VistaRpc.COUNT_WIDTH) + 'f'
             elif param.type == RpcParameter.LIST:
                 param_str += '2' + RpcParameter.list_to_string(param.value)
             else:
                 raise VistaException('Invalid param type')
     if param_str == '5': param_str += '4f'
     return param_str
Beispiel #10
0
    def __prepare_param_list(self):
        if not getattr(self, 'file', None):
            raise VistaException('VistaSelect must specify a file')
        self.param_list = [('"FILE"', self.file)]

        if getattr(self, 'iens', None):
            self.param_list += [('"IENS"', self.iens)]

        self.param_list += [('"FIELDS"', getattr(self, 'fields', '@'))]

        self.param_list += [('"FLAGS"', getattr(self, 'flags', 'IP'))]

        if getattr(self, 'number', None):
            self.param_list += [('"MAX"', str(self.number))]

        if getattr(self, 'frum', None):
            self.param_list += [('"FROM"',
                                 VistaUtils.adjust_for_search(self.frum))]

        if getattr(self, 'part', None):
            self.param_list += [('"PART"', self.part)]

        self.param_list += [('"XREF"', getattr(self, 'index', '#'))]

        if getattr(self, 'screen', None):
            self.param_list += [('"SCREEN"', self.screen)]

        if getattr(self, 'identifier', None):
            self.param_list += [('"ID"', self.identifier)]

        return self.param_list
Beispiel #11
0
 def test_adjust_for_string_search(self):
     expected = "Snurc~"
     actual = VistaUtils._VistaUtils__adjust_for_string_search("Snurd")
     self.assertEqual(expected, actual)
Beispiel #12
0
 def test_adjust_for_numeric_search(self):
     expected = "244"
     actual = VistaUtils._VistaUtils__adjust_for_numeric_search("245")
     self.assertEqual(expected, actual)
Beispiel #13
0
 def test_adjust_for_numeric_search(self):
     expected = "244"
     actual = VistaUtils._VistaUtils__adjust_for_numeric_search("245")
     self.assertEqual(expected, actual)
Beispiel #14
0
 def test_adjust_for_string_search(self):
     expected = "Snurc~"
     actual = VistaUtils._VistaUtils__adjust_for_string_search("Snurd")
     self.assertEqual(expected, actual)
Beispiel #15
0
 def __connect_rpc(params):
     return "[XWB]10304\x0ATCPConnect50" + VistaUtils.str_pack(params[0].value, VistaRpc.COUNT_WIDTH) + \
             "f0" + VistaUtils.str_pack('0', VistaRpc.COUNT_WIDTH) + \
             "f0" + VistaUtils.str_pack(params[1].value, VistaRpc.COUNT_WIDTH) + \
             "f" + VistaRpc.EOT
Beispiel #16
0
 def test_str_pack(self):
     expected = "0000000015something!5here"
     actual = VistaUtils.str_pack("something!5here", 10)
     self.assertEqual(expected, actual)
Beispiel #17
0
 def prepare_standard_rpc(rpc_name, param_string):
     return VistaRpc.PREFIX + '11302' + VistaUtils.prepend_count(VistaRpc.RPC_VERSION) + \
             VistaUtils.prepend_count(rpc_name) + param_string + VistaRpc.EOT
Beispiel #18
0
 def prepare_standard_rpc(rpc_name, param_string):
     return VistaRpc.PREFIX + '11302' + VistaUtils.prepend_count(VistaRpc.RPC_VERSION) + \
             VistaUtils.prepend_count(rpc_name) + param_string + VistaRpc.EOT
Beispiel #19
0
 def test_str_pack(self):
     expected = "0000000015something!5here"
     actual = VistaUtils.str_pack("something!5here", 10)
     self.assertEqual(expected, actual)
Beispiel #20
0
 def __connect_rpc(params):
     return "[XWB]10304\x0ATCPConnect50" + VistaUtils.str_pack(params[0].value, VistaRpc.COUNT_WIDTH) + \
             "f0" + VistaUtils.str_pack('0', VistaRpc.COUNT_WIDTH) + \
             "f0" + VistaUtils.str_pack(params[1].value, VistaRpc.COUNT_WIDTH) + \
             "f" + VistaRpc.EOT