def test_apply_action_invalid(self): rule = rules.Integer(action=None) self.assertRaises(Exception, rule.apply, 'a')
def test_apply_action_droprow(self): rule = rules.Integer(action=rules.Integer.ACTION_DROPROW) self.assertEqual(rule.apply('3'), 3) self.assertRaises(errors.DropRow, rule.apply, 'a')
def test_apply_action_zero(self): rule = rules.Integer(action=rules.Integer.ACTION_ZERO) self.assertEqual(rule.apply('3'), 3) self.assertEqual(rule.apply('a'), 0)
def test_apply_invalid_integer(self): rule = rules.Integer() self.assertRaises(Exception, rule.apply, 'a')
def test_apply_string_integer(self): rule = rules.Integer() self.assertEqual(rule.apply('3'), 3)
def test_writerow(self): writer = mock.MagicMock() r_rules = [[rules.Integer(action=rules.Integer.ACTION_DROPROW)]] r = rigidity.Rigidity(writer, r_rules) r.writerow(['a']) self.assertFalse(writer.writerow.called)