def test_filter_ignores_non_filter_query_args(self): assert_equal( filter_clause( MultiDict({'fieldName': ['Aa bb'], 'lot': ['saas']}) ), {'bool': {'must': []}} )
def test_filter_ignores_non_filter_query_args(self): assert_equal( filter_clause(MultiDict({ 'fieldName': ['Aa bb'], 'lot': ['saas'] })), {'bool': { 'must': [] }})
def test_single_or_field(self): assert_equal( filter_clause(MultiDict({'filter_fieldName': ['Aa,Bb']})), {'bool': { 'must': [ {"terms": {"filter_fieldName": ['aa', 'bb'], "execution": "bool"}}, ] }} )
def test_or_and_combination(self, services_mapping): bool_filter = filter_clause(services_mapping, MultiDict({ 'filter_andFieldName': ['Aa', 'bb'], 'filter_orFieldName': ['Aa,Bb'] })) assert {"terms": {"dmfilter_orFieldName": ['Aa', 'Bb']}} in bool_filter['bool']['must'] assert {"term": {"dmfilter_andFieldName": 'Aa'}} in bool_filter['bool']['must'] assert {"term": {"dmfilter_andFieldName": 'bb'}} in bool_filter['bool']['must']
def test_single_and_field(self): assert_equal( filter_clause(MultiDict( {'filter_fieldName': ['Aa bb'], 'lot': 'saas'} )), {'bool': { 'must': [ {"term": {"filter_fieldName": 'aabb'}}, ] }} )
def test_single_or_field(self): assert_equal( filter_clause(MultiDict({'filter_fieldName': ['Aa,Bb']})), { 'bool': { 'must': [ { "terms": { "filter_fieldName": ['aa', 'bb'], "execution": "bool" } }, ] } })
def test_single_and_field(self): assert_equal( filter_clause( MultiDict({ 'filter_fieldName': ['Aa bb'], 'lot': 'saas' })), {'bool': { 'must': [ { "term": { "filter_fieldName": 'aabb' } }, ] }})
def test_or_and_combination(self): bool_filter = filter_clause(MultiDict({ 'filter_andFieldName': ['Aa', 'bb'], 'filter_orFieldName': ['Aa,Bb'] })) assert_in( {"terms": {"filter_orFieldName": ['aa', 'bb'], "execution": "bool"}}, bool_filter['bool']['must'] ) assert_in( {"term": {"filter_andFieldName": 'aa'}}, bool_filter['bool']['must'] ) assert_in( {"term": {"filter_andFieldName": 'bb'}}, bool_filter['bool']['must'] )
def test_or_and_combination(self): bool_filter = filter_clause( MultiDict({ 'filter_andFieldName': ['Aa', 'bb'], 'filter_orFieldName': ['Aa,Bb'] })) assert_in( { "terms": { "filter_orFieldName": ['aa', 'bb'], "execution": "bool" } }, bool_filter['bool']['must']) assert_in({"term": { "filter_andFieldName": 'aa' }}, bool_filter['bool']['must']) assert_in({"term": { "filter_andFieldName": 'bb' }}, bool_filter['bool']['must'])
def test_single_or_field(self, services_mapping): assert ( filter_clause(services_mapping, MultiDict({'filter_fieldName': ['Aa,Bb']})) == {'bool': {'must': [{"terms": {"dmfilter_fieldName": ['Aa', 'Bb']}}]}} )
def test_single_and_field(self, services_mapping): assert ( filter_clause(services_mapping, MultiDict({'filter_fieldName': ['Aa bb'], 'lot': 'saas'})) == {'bool': {'must': [{"term": {"dmfilter_fieldName": 'Aa bb'}}]}} )
def test_filter_ignores_non_filter_query_args(self, services_mapping): assert ( filter_clause(services_mapping, MultiDict({'fieldName': ['Aa bb'], 'lot': ['saas']})) == {'bool': {'must': []}} )