Example #1
0
    def test_read_write_list_accessors(self, rw_data):
        dc = DataCategoryBase('test', attributeNameList=['a', 'b', 'c', 'd'])

        dc.append([1, 2, 3, 4])
        dc.append([1, 2, 3, 4])
        dc.append([1, 2, 3, 4])
        dc.append([1, 2, 3, 4, 5, 6, 7])
        dc.append([1, 2, 3, 4])

        dc.insert(0, [4, 3, 2, 1])

        print("Full  %r\n" % dc)
        print("slice %r\n" % dc[2:4])
        print("last  %r\n" % dc[-1])

        for r in dc:
            print("row data %r\n" % r)

        dc.setMapping('ATTRIBUTE')
        for r in dc:
            print("row attrib dict %r\n" % r)

        dc.setMapping('ITEM')
        for r in dc:
            print("row item dict %r\n" % r)

        dc.setMapping('DATA')

        print("row 3 %r\n" % dc[3])
        tmp = dc[3]
        dc[3] = []
        print("row 3 %r\n" % dc[3])
        dc[3] = tmp
        print("row 3 %r\n" % dc[3])

        dc.setMapping('ATTRIBUTE')
        tmp = dc[3]

        dt = {}
        for k, v in tmp.items():
            dt[k] = 10000
        print("row dict %r\n" % dt)

        dc[3] = dt
        print("row 3%r\n" % dc[3])
        dc[3] = tmp

        dc.setMapping('ITEM')
        tmp = dc[3]

        dt = {}
        for k, v in tmp.items():
            dt[k] = 10001
        print("row dict %r\n" % dt)

        dc[3] = dt
        print("row 3 %r\n" % dc[3])

        print("print raw     %r\n" % dc)
        print("print string  %s\n" % dc)
Example #2
0
    def testReadWriteListAccessors(self):
        """Test cases -  for list style data access."""
        try:
            dc = DataCategoryBase("test", attributeNameList=["a", "b", "c", "d"])

            dc.append([1, 2, 3, 4])
            dc.append([1, 2, 3, 4])
            dc.append([1, 2, 3, 4])
            dc.append([1, 2, 3, 4, 5, 6, 7])
            dc.append([1, 2, 3, 4])

            dc.insert(0, [4, 3, 2, 1])

            logger.debug("Full  %r", dc)
            logger.debug("slice %r", dc[2:4])
            logger.debug("last  %r", dc[-1])

            for rV in dc:
                logger.debug("row data %r", rV)

            dc.setMapping("ATTRIBUTE")
            for rV in dc:
                logger.debug("row attrib dict %r", rV)

            dc.setMapping("ITEM")
            for rV in dc:
                logger.debug("row item dict %r", rV)

            dc.setMapping("DATA")

            logger.debug("row 3 %r", dc[3])
            tmp = dc[3]
            dc[3] = []
            logger.debug("row 3 %r", dc[3])
            dc[3] = tmp
            logger.debug("row 3 %r", dc[3])

            dc.setMapping("ATTRIBUTE")
            tmp = dc[3]

            dt = {}
            for k, _ in tmp.items():
                dt[k] = 10000
            logger.debug("row dict %r", dt)

            dc[3] = dt
            logger.debug("row 3%r", dc[3])
            dc[3] = tmp

            dc.setMapping("ITEM")
            tmp = dc[3]

            dt = {}
            for k, _ in tmp.items():
                dt[k] = 10001
            logger.debug("row dict %r", dt)

            dc[3] = dt
            logger.debug("row 3 %r", dc[3])

            logger.debug("print raw     %r", dc)
            logger.debug("print string  %s", dc)
            self.assertEqual(1, 1)
        except Exception as e:
            logger.exception("Failing with %s", str(e))
            self.fail()