コード例 #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)