def test_invalid_search_field(self): """ Tests the clean() method of a ContextFilter when the search_field is invalid. """ context_filter = ContextFilter(context=self.context_w_filters, value_field='user.email', operator='eq', search_field='host') msg = 'The search field "host" is not a field in the Container used '\ 'by the Related Distillery elasticsearch.test_index.test_docs.' with six.assertRaisesRegex(self, ValidationError, msg): context_filter.clean()
def test_valid_filter(self): """ Tests the clean() method of a ContextFilter when the value_field and search_field are valid. """ context_filter = ContextFilter(context=self.context_w_filters, value_field='user.email', operator='regex', search_field='user.email') try: context_filter.clean() except ValidationError: self.fail('A ValidationError was raised unexpectedly')
def test_invalid_value_field(self): """ Tests the clean() method of a ContextFilter when the value_field is invalid. """ context_filter = ContextFilter(context=self.context_w_filters, value_field='host', operator='eq', search_field='from') msg = 'The value field "host" is not a field in the Container used '\ 'by the Focal Distillery mongodb.test_database.test_posts.' with six.assertRaisesRegex(self, ValidationError, msg): context_filter.clean()