def should_separate_type_and_subtypes(self):
     options = dict(type='land,dryad')
     request = SearchRequest(options)
     subt = SearchFilter('subtype', keywords=[SearchKeyword('dryad', 'and')])
     type_ = SearchFilter('type', keywords=[SearchKeyword('land', 'and')])
     self.assertEqual(request.get_filters(), {'type':type_,
                                              'subtype': subt})
 def should_separate_many_types_with_not_modifier(self):
     options = dict(type='legendary,artifact,!equipment,!creature')
     request = SearchRequest(options)
     type_keywords = [SearchKeyword('legendary', 'and'),
                      SearchKeyword('artifact', 'and'),
                      SearchKeyword('creature', 'not')]
     subtype_keywords = [SearchKeyword('equipment', 'not')]
     subt = SearchFilter('subtype', keywords=subtype_keywords)
     type_ = SearchFilter('type', keywords=type_keywords)
     self.assertEqual(request.get_filters(), {'type': type_,
                                              'subtype': subt})
 def should_group_text_in_brackets(self):
     word = SearchKeyword('trample', 'and')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+[trample]')
 def should_assume_exact_quote_if_spaces(self):
     word = SearchKeyword('first strike', 'and')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+["first strike"]')
 def should_not_quote_rarities(self):
     word = SearchKeyword('M', 'and')
     fl = SearchFilter('rarity', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'rarity=+[M]')
 def should_group_url_keywords_if_excluding_others(self):
     word = SearchKeyword('w', 'and')
     fl = SearchFilter('color', keywords=[word])
     fl.exclude_others = True
     self.assertEqual(fl.url_fragment(), 'color=+@(+[w])')
 def should_render_equality_comparison(self):
     word = SearchKeyword(5, 'and', '=')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+=[5]')
 def should_render_greater_than_comparison(self):
     word = SearchKeyword(5, 'and', '>')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+>[5]')
 def should_group_url_keywords_if_excluding_others(self):
     word = SearchKeyword('w', 'and')
     fl = SearchFilter('color', keywords=[word])
     fl.exclude_others = True
     self.assertEqual(fl.url_fragment(), 'color=+@(+[w])')
Exemple #10
0
 def should_separate_and_words(self):
     sengir = SearchKeyword('sengir', 'and')
     vampire = SearchKeyword('vampire', 'and')
     fl = SearchFilter('name', keywords=[sengir, vampire])
     self.assertEqual(fl.url_fragment(), 'name=+[sengir]+[vampire]')
Exemple #11
0
 def should_render_equality_comparison(self):
     word = SearchKeyword(5, 'and', '=')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+=[5]')
Exemple #12
0
 def should_render_less_than_or_equal_to_comparison(self):
     word = SearchKeyword(5, 'and', '<=')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+<=[5]')
Exemple #13
0
 def should_render_greater_than_comparison(self):
     word = SearchKeyword(5, 'and', '>')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+>[5]')
Exemple #14
0
 def should_parse_logical_or(self):
     first = SearchKeyword('first', 'or')
     strike = SearchKeyword('strike', 'or')
     fl = SearchFilter('text', keywords=[first, strike])
     self.assertEqual(fl.url_fragment(), 'text=|[first]|[strike]')
Exemple #15
0
 def should_assume_exact_quote_if_spaces(self):
     word = SearchKeyword('first strike', 'and')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+["first strike"]')
Exemple #16
0
 def should_parse_logical_or(self):
     first = SearchKeyword('first', 'or')
     strike = SearchKeyword('strike', 'or')
     fl = SearchFilter('text', keywords=[first, strike])
     self.assertEqual(fl.url_fragment(), 'text=|[first]|[strike]')
Exemple #17
0
 def should_group_url_keywords_if_excluding_other_types(self):
     word = SearchKeyword('goblin', 'and')
     fl = SearchFilter('type', keywords=[word])
     fl.exclude_others = True
     self.assertEqual(fl.url_fragment(), 'type=+@(+[goblin])')
Exemple #18
0
 def should_render_less_than_or_equal_to_comparison(self):
     word = SearchKeyword(5, 'and', '<=')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+<=[5]')
Exemple #19
0
 def should_not_quote_rarities(self):
     word = SearchKeyword('M', 'and')
     fl = SearchFilter('rarity', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'rarity=+[M]')
Exemple #20
0
 def should_separate_and_words(self):
     sengir = SearchKeyword('sengir', 'and')
     vampire = SearchKeyword('vampire', 'and')
     fl = SearchFilter('name', keywords=[sengir, vampire])
     self.assertEqual(fl.url_fragment(), 'name=+[sengir]+[vampire]')
Exemple #21
0
 def should_render_not_operator(self):
     word = SearchKeyword('graveyard', 'not')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+![graveyard]')
Exemple #22
0
 def should_group_url_keywords_if_excluding_other_types(self):
     word = SearchKeyword('goblin', 'and')
     fl = SearchFilter('type', keywords=[word])
     fl.exclude_others = True
     self.assertEqual(fl.url_fragment(), 'type=+@(+[goblin])')
Exemple #23
0
 def should_recognize_creature_type_as_subtype(self):
     options = dict(type='dryad')
     request = SearchRequest(options)
     fl = SearchFilter('subtype', keywords=[SearchKeyword('dryad', 'and')])
     self.assertEqual(request.get_filters(), {'subtype': fl})
Exemple #24
0
 def should_render_not_operator(self):
     word = SearchKeyword('graveyard', 'not')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+![graveyard]')
Exemple #25
0
 def should_group_text_in_brackets(self):
     word = SearchKeyword('trample', 'and')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+[trample]')