Exemplo n.º 1
0
 def test_base_methods_unicode(self, category_data):
     name = 'A'
     dcbA = DataCategoryBase(name, category_data['attributeList'],
                             category_data['rowListUnicode'])
     assert name == dcbA.getName()
     assert category_data['attributeList'] == dcbA.getAttributeList()
     assert category_data['rowListUnicode'] == dcbA.getRowList()
     assert len(category_data['rowListUnicode']) == dcbA.getRowCount()
     ii = 0
     dcbA.setMapping('DATA')
     for row in dcbA:
         ii += 1
         assert category_data['testRowUnicode'] == row[1:]
     assert ii == dcbA.getRowCount()
     dcbA.setMapping('ATTRIBUTE')
     ii = 0
     na = len(dcbA.getAttributeList())
     for row in dcbA:
         ii += 1
         # logger.info("ii %d row %r " % (ii, row))
         assert ii == row['colOrd']
         assert category_data['testRowUnicode'][na - 2] == row['colD']
         #
     assert ii == dcbA.getRowCount()
     dcbA.setMapping('ITEM')
     ii = 0
     for row in dcbA:
         ii += 1
         assert ii == row['_' + name + '.' + 'colOrd']
         assert category_data['testRowUnicode'][3] == row['_' + name + '.' +
                                                          'colD']
     assert ii == dcbA.getRowCount()
Exemplo n.º 2
0
    def test_base_methods_ascii(self, category_data):
        name = 'A'
        dcbA = DataCategoryBase(name, category_data['attributeList'],
                                category_data['rowListAsciiA'])
        assert name == dcbA.getName()
        assert category_data['attributeList'] == dcbA.getAttributeList()
        assert category_data['rowListAsciiA'] == dcbA.getRowList()
        assert len(category_data['rowListAsciiA']) == dcbA.getRowCount()
        ii = 0
        dcbA.setMapping('DATA')
        for row in dcbA:
            ii += 1
            assert category_data['testRowAsciiA'] == row[1:]
        assert ii == dcbA.getRowCount()
        dcbA.setMapping('ATTRIBUTE')
        ii = 0
        na = len(dcbA.getAttributeList())
        for row in dcbA:
            ii += 1
            assert ii == row['colOrd']
            assert category_data['testRowAsciiA'][na - 2] == row['colD']

        assert ii == dcbA.getRowCount()
        dcbA.setMapping('ITEM')
        ii = 0
        for row in dcbA:
            ii += 1
            assert ii == row['_' + name + '.' + 'colOrd']
        assert ii == dcbA.getRowCount()
Exemplo n.º 3
0
 def testBaseMethodsAscii(self):
     """Test case -  base class methods"""
     try:
         name = "A"
         dcbA = DataCategoryBase(name, self.__attributeList,
                                 self.__rowListAsciiA)
         self.assertEqual(name, dcbA.getName())
         self.assertEqual(self.__attributeList, dcbA.getAttributeList())
         self.assertEqual(self.__rowListAsciiA, dcbA.getRowList())
         self.assertEqual(len(self.__rowListAsciiA), dcbA.getRowCount())
         ii = 0
         dcbA.setMapping("DATA")
         for row in dcbA:
             ii += 1
             self.assertEqual(self.__testRowAsciiA, row[1:])
         self.assertEqual(ii, dcbA.getRowCount())
         dcbA.setMapping("ATTRIBUTE")
         ii = 0
         na = len(dcbA.getAttributeList())
         for row in dcbA:
             ii += 1
             # logger.info("ii %d row %r " % (ii, row))
             self.assertEqual(ii, row["colOrd"])
             self.assertEqual(self.__testRowAsciiA[na - 2], row["colD"])
             #
         self.assertEqual(ii, dcbA.getRowCount())
         dcbA.setMapping("ITEM")
         ii = 0
         for row in dcbA:
             ii += 1
             self.assertEqual(ii, row["_" + name + "." + "colOrd"])
         self.assertEqual(ii, dcbA.getRowCount())
     except Exception as e:
         logger.exception("Failing with %s", str(e))
         self.fail()