def setUp(self): self.errors = [] self.schema = Schema(rules=[ SchemaRule('#sector', min_occur=1), SchemaRule('#affected', data_type='number') ], callback=lambda error: self.errors.append(error)) self.row = Row(columns=[ Column(tag='#affected'), Column(tag='#sector'), Column(tag='#sector') ])
def test_row_restrictions(self): row = Row(columns=[ Column(tag='#x_test'), Column(tag='#subsector'), Column(tag='#x_test') ], values=['WASH', '', '']) self.rule.min_occur = 1 self._try_rule(row) self.rule.min_occur = 2 self._try_rule(row, 1) self.rule.min_occur = None self.rule.max_occur = 1 self._try_rule(row) self.rule.max_occur = 0 self._try_rule(row, 1)
def test_wildcard_empty_column(self): pattern = TagPattern.parse('*') untagged_column = Column(header="Foo", column_number=1) self.assertFalse(pattern.match(untagged_column))
def setUp(self): self.column = Column(tag='#tag', attributes=['foo', 'bar'])
def test_hash(self): col1 = Column(tag='xxx', attributes={'b', 'c', 'a'}, header='foo') col2 = Column(tag='xxx', attributes={'a', 'b', 'c'}, header='bar') col3 = Column(tag='xxx', attributes={'b', 'c'}) self.assertEqual(hash(col1), hash(col2)) self.assertNotEqual(hash(col1), hash(col3))
def test_case_insensitive(self): column = Column(tag='Foo', attributes=['X', 'y']) self.assertEqual('foo', column.tag) self.assertEqual(set(['x', 'y']), column.attributes)
def setUp(self): self.column = Column(tag=TestColumn.HXL_TAG, attributes=TestColumn.ATTRIBUTES, header=TestColumn.HEADER_TEXT)