예제 #1
0
 def test_apply_action_invalid(self):
     rule = rules.Integer(action=None)
     self.assertRaises(Exception, rule.apply, 'a')
예제 #2
0
 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')
예제 #3
0
 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)
예제 #4
0
 def test_apply_invalid_integer(self):
     rule = rules.Integer()
     self.assertRaises(Exception, rule.apply, 'a')
예제 #5
0
 def test_apply_string_integer(self):
     rule = rules.Integer()
     self.assertEqual(rule.apply('3'), 3)
예제 #6
0
 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)