Exemplo n.º 1
0
 def test_empty(self):
     """Test empty value."""
     fltr = filters.SimpleFilter('field',
                                 'param',
                                 transformers=[lambda v: '1'],
                                 required=False)
     fltr.add(self.query, {'param': ''})
     self.query.filter.assert_not_called()
Exemplo n.º 2
0
 def test_transform(self):
     """Test transform."""
     fltr = filters.SimpleFilter('field',
                                 'param',
                                 transformers=[lambda v: '1'],
                                 required=False)
     fltr.add(self.query, {'param': 'test'})
     self.query.filter.assert_called_once_with('field', '1')
Exemplo n.º 3
0
  def test_empty_required(self):
    """Test required value."""
    fltr = filters.SimpleFilter(
        'field', 'param', transformers=[lambda v: '1'], required=True)

    with self.assertRaises(helpers.EarlyExitException) as cm:
      fltr.add(self.query, {'param': ''})

    self.assertEqual("'param' is required.", cm.exception.message)
    self.assertEqual(400, cm.exception.status)
    self.query.filter.assert_not_called()