def test_and_clause_push_down_supermodel(self): results = normalize_query([{ '_model': 'Human', 'or': [{ 'field': 'nickname', 'value': 'Johnny' }, { 'field': 'nickname', 'value': 'Winny' }] }, { '_model': 'Proxy' }]) assert results == [{ '_model': 'Human', 'or': [{ '_model': 'Human', 'field': 'nickname', 'value': 'Johnny' }, { '_model': 'Human', 'field': 'nickname', 'value': 'Winny' }] }, { '_model': 'Proxy' }]
def test_or_clause(self): results = normalize_query([{ '_model': 'Human', 'or': [{ '_model': 'Human', 'field': 'nickname', 'value': 'Johnny' }, { '_model': 'Human', 'field': 'nickname', 'value': 'Winny' }] }, { '_model': 'Proxy' }]) assert results == [{ '_model': 'Human', 'or': [{ '_model': 'Human', 'field': 'nickname', 'value': 'Johnny' }, { '_model': 'Human', 'field': 'nickname', 'value': 'Winny' }] }, { '_model': 'Proxy' }]
def test_and_clause_no_model(self): results = normalize_query([{ 'and': [{ '_model': 'Human' }, { '_model': 'Human', 'field': 'nickname', 'value': 'Johnny' }] }, { '_model': 'Proxy' }]) assert results == [{ '_model': 'Human', 'and': [{ '_model': 'Human' }, { '_model': 'Human', 'field': 'nickname', 'value': 'Johnny' }] }, { '_model': 'Proxy' }]
def test_two_strings(self): results = normalize_query(['Human', 'Proxy']) assert results == [{ '_model': 'Human', '_label': 'Human' }, { '_model': 'Proxy', '_label': 'Proxy' }] results = normalize_query(['Proxy', 'Human']) assert results == [{ '_model': 'Proxy', '_label': 'Proxy' }, { '_model': 'Human', '_label': 'Human' }]
def test_one_dict_in_a_list(self): results = normalize_query([{'_model':'Human'}]) assert results == [{'_model':'Human'}]
def test_one_dict(self): results = normalize_query({'_model':'Human'}) assert results == [{'_model':'Human'}]
def test_two_strings(self): results = normalize_query(['Human', 'Proxy']) assert results == [{'_model':'Human', '_label':'Human'}, {'_model':'Proxy', '_label':'Proxy'}] results = normalize_query(['Proxy', 'Human']) assert results == [{'_model':'Proxy', '_label':'Proxy'}, {'_model':'Human', '_label':'Human'}]
def test_one_string_in_a_list(self): results = normalize_query(['Human']) assert results == [{'_model':'Human', '_label':'Human'}]
def test_one_string(self): results = normalize_query('Human') assert results == [{'_model':'Human', '_label':'Human'}]
def test_and_clause_push_down_supermodel(self): results = normalize_query([{'_model':'Human', 'or':[{'field':'nickname', 'value':'Johnny'}, {'field':'nickname', 'value':'Winny'}]}, {'_model':'Proxy'}]) assert results == [{'_model':'Human', 'or':[{'_model':'Human', 'field':'nickname', 'value':'Johnny'}, {'_model':'Human', 'field':'nickname', 'value':'Winny'}]}, {'_model':'Proxy'}]
def test_one_dict_in_a_list(self): results = normalize_query([{'_model':'Human'}]) self.assertEquals(results, [{'_model':'Human'}])
def test_two_strings(self): results = normalize_query(['Human', 'Proxy']) self.assertEquals(results, [{'_model':'Human', '_label':'Human'}, {'_model':'Proxy', '_label':'Proxy'}]) results = normalize_query(['Proxy', 'Human']) self.assertEquals(results, [{'_model':'Proxy', '_label':'Proxy'}, {'_model':'Human', '_label':'Human'}])
def test_one_string_in_a_list(self): results = normalize_query(['Human']) self.assertEquals(results, [{'_model':'Human', '_label':'Human'}])
def test_one_string(self): results = normalize_query('Human') self.assertEquals(results, [{'_model':'Human', '_label':'Human'}])
def test_two_dicts(self): results = normalize_query([{'_model':'Human'}, {'_model':'Proxy'}]) assert results == [{'_model':'Human'}, {'_model':'Proxy'}] results = normalize_query([{'_model':'Proxy'}, {'_model':'Human'}]) assert results == [{'_model':'Proxy'}, {'_model':'Human'}]
def test_or_clause(self): results = normalize_query([{'_model':'Human', 'or':[{'_model':'Human', 'field':'nickname', 'value':'Johnny'}, {'_model':'Human', 'field':'nickname', 'value':'Winny'}]}, {'_model':'Proxy'}]) assert results == [{'_model':'Human', 'or':[{'_model':'Human', 'field':'nickname', 'value':'Johnny'}, {'_model':'Human', 'field':'nickname', 'value':'Winny'}]}, {'_model':'Proxy'}]
def test_two_dicts(self): results = normalize_query([{'_model':'Human'}, {'_model':'Proxy'}]) self.assertEquals(results, [{'_model':'Human'}, {'_model':'Proxy'}]) results = normalize_query([{'_model':'Proxy'}, {'_model':'Human'}]) self.assertEquals(results, [{'_model':'Proxy'}, {'_model':'Human'}])
def test_and_clause_no_model(self): results = normalize_query([{'and':[{'_model':'Human'}, {'_model':'Human', 'field':'nickname', 'value':'Johnny'}]}, {'_model':'Proxy'}]) assert results == [{'_model':'Human', 'and':[{'_model':'Human'}, {'_model':'Human', 'field':'nickname', 'value':'Johnny'}]}, {'_model':'Proxy'}]
def test_and_clause(self): results = normalize_query([{'_model':'Human', 'and':[{'_model':'Human', 'field':'nickname', 'value':'Johnny'}, {'_model':'Human', 'field':'nickname', 'value':'Winny'}]}, {'_model':'Proxy'}]) self.assertEquals(results, [{'_model':'Human', 'and':[{'_model':'Human', 'field':'nickname', 'value':'Johnny'}, {'_model':'Human', 'field':'nickname', 'value':'Winny'}]}, {'_model':'Proxy'}])