Beispiel #1
0
    def test_gen_query_inp(self):
        gq = GenQueryRequest()
        gq.maxRows = 4
        gq.continueInx = 3
        gq.partialStartIndex = 2
        gq.options = 1

        kvp = StringStringMap()
        kvp.ssLen = 2
        kvp.keyWord = ['one', 'two']
        kvp.svalue = ['three', 'four']

        iip = IntegerIntegerMap()
        iip.iiLen = 2
        iip.inx = [4, 5]
        iip.ivalue = [1, 2]

        ivp = IntegerStringMap()
        ivp.isLen = 2
        ivp.inx = [1, 2]
        ivp.svalue = ['five', 'six']

        gq.KeyValPair_PI = kvp
        gq.InxIvalPair_PI = iip
        gq.InxValPair_PI = ivp

        expected = "<GenQueryInp_PI><maxRows>4</maxRows><continueInx>3</continueInx><partialStartIndex>2</partialStartIndex><options>1</options><KeyValPair_PI><ssLen>2</ssLen><keyWord>one</keyWord><keyWord>two</keyWord><svalue>three</svalue><svalue>four</svalue></KeyValPair_PI><InxIvalPair_PI><iiLen>2</iiLen><inx>4</inx><inx>5</inx><ivalue>1</ivalue><ivalue>2</ivalue></InxIvalPair_PI><InxValPair_PI><isLen>2</isLen><inx>1</inx><inx>2</inx><svalue>five</svalue><svalue>six</svalue></InxValPair_PI></GenQueryInp_PI>"
        self.assertEqual(gq.pack(), expected)

        gq2 = GenQueryRequest()
        gq2.unpack(ET().fromstring(expected))
        self.assertEqual(gq2.maxRows, 4)
        self.assertEqual(gq2.continueInx, 3)
        self.assertEqual(gq2.partialStartIndex, 2)
        self.assertEqual(gq2.options, 1)

        self.assertEqual(gq2.KeyValPair_PI.ssLen, 2)
        self.assertEqual(gq2.KeyValPair_PI.keyWord, ["one", "two"])
        self.assertEqual(gq2.KeyValPair_PI.svalue, ["three", "four"])

        self.assertEqual(gq2.InxIvalPair_PI.iiLen, 2)
        self.assertEqual(gq2.InxIvalPair_PI.inx, [4, 5])
        self.assertEqual(gq2.InxIvalPair_PI.ivalue, [1, 2])

        self.assertEqual(gq2.InxValPair_PI.isLen, 2)
        self.assertEqual(gq2.InxValPair_PI.inx, [1, 2])
        self.assertEqual(gq2.InxValPair_PI.svalue, ["five", "six"])

        self.assertEqual(gq2.pack(), expected)
    def test_gen_query_inp(self):
        gq = GenQueryRequest()
        gq.maxRows = 4
        gq.continueInx = 3
        gq.partialStartIndex = 2
        gq.options = 1

        kvp = StringStringMap()
        kvp.ssLen = 2
        kvp.keyWord = ['one', 'two']
        kvp.svalue = ['three', 'four']

        iip = IntegerIntegerMap()
        iip.iiLen = 2
        iip.inx = [4, 5]
        iip.ivalue = [1, 2]

        ivp = IntegerStringMap()
        ivp.isLen = 2
        ivp.inx = [1, 2]
        ivp.svalue = ['five', 'six']

        gq.KeyValPair_PI = kvp
        gq.InxIvalPair_PI = iip
        gq.InxValPair_PI = ivp

        expected = "<GenQueryInp_PI><maxRows>4</maxRows><continueInx>3</continueInx><partialStartIndex>2</partialStartIndex><options>1</options><KeyValPair_PI><ssLen>2</ssLen><keyWord>one</keyWord><keyWord>two</keyWord><svalue>three</svalue><svalue>four</svalue></KeyValPair_PI><InxIvalPair_PI><iiLen>2</iiLen><inx>4</inx><inx>5</inx><ivalue>1</ivalue><ivalue>2</ivalue></InxIvalPair_PI><InxValPair_PI><isLen>2</isLen><inx>1</inx><inx>2</inx><svalue>five</svalue><svalue>six</svalue></InxValPair_PI></GenQueryInp_PI>"
        self.assertEqual(gq.pack(), expected)

        gq2 = GenQueryRequest()
        gq2.unpack(ET.fromstring(expected))
        self.assertEqual(gq2.maxRows, 4)
        self.assertEqual(gq2.continueInx, 3)
        self.assertEqual(gq2.partialStartIndex, 2)
        self.assertEqual(gq2.options, 1)

        self.assertEqual(gq2.KeyValPair_PI.ssLen, 2)
        self.assertEqual(gq2.KeyValPair_PI.keyWord, ["one", "two"])
        self.assertEqual(gq2.KeyValPair_PI.svalue, ["three", "four"])

        self.assertEqual(gq2.InxIvalPair_PI.iiLen, 2)
        self.assertEqual(gq2.InxIvalPair_PI.inx, [4, 5])
        self.assertEqual(gq2.InxIvalPair_PI.ivalue, [1, 2])

        self.assertEqual(gq2.InxValPair_PI.isLen, 2)
        self.assertEqual(gq2.InxValPair_PI.inx, [1, 2])
        self.assertEqual(gq2.InxValPair_PI.svalue, ["five", "six"])

        self.assertEqual(gq2.pack(), expected)
    def test_key_val_pair(self):
        kvp = StringStringMap()
        kvp.ssLen = 2
        kvp.keyWord = ["one", "two"]
        kvp.svalue = ["three", "four"]
        expected = "<KeyValPair_PI>\
<ssLen>2</ssLen>\
<keyWord>one</keyWord>\
<keyWord>two</keyWord>\
<svalue>three</svalue>\
<svalue>four</svalue>\
</KeyValPair_PI>"
        self.assertEqual(kvp.pack(), expected)

        kvp2 = StringStringMap()
        kvp2.unpack(ET.fromstring(expected))
        self.assertEqual(kvp2.ssLen, 2)
        self.assertEqual(kvp2.keyWord, ["one", "two"])
        self.assertEqual(kvp2.svalue, ["three", "four"])
    def test_key_val_pair(self):
        kvp = StringStringMap()
        kvp.ssLen = 2
        kvp.keyWord = ["one", "two"]
        kvp.svalue = ["three", "four"]
        expected = "<KeyValPair_PI>\
<ssLen>2</ssLen>\
<keyWord>one</keyWord>\
<keyWord>two</keyWord>\
<svalue>three</svalue>\
<svalue>four</svalue>\
</KeyValPair_PI>"
        self.assertEqual(kvp.pack(), expected)

        kvp2 = StringStringMap()
        kvp2.unpack(ET.fromstring(expected))
        self.assertEqual(kvp2.ssLen, 2)
        self.assertEqual(kvp2.keyWord, ["one", "two"])
        self.assertEqual(kvp2.svalue, ["three", "four"])