コード例 #1
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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})
コード例 #2
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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})
コード例 #3
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_correctly_combine_not_and_and(self):
     parser = ConditionParser({'color': '!b,r'})
     cond = parser.get_conditions()
     self.assertEqual(cond['color'].keywords, [SearchKeyword('B', 'not'),
                                               SearchKeyword('R', 'and')])
コード例 #4
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_understand_equality_conditional(self):
     parser = ConditionParser({'tough': '=3'})
     cond = parser.get_conditions()
     self.assertEqual(cond['tough'].keywords, [SearchKeyword(3, 'and', '=')])
コード例 #5
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_understand_multiple_conditionals(self):
     parser = ConditionParser({'power': '<5,>0'})
     cond = parser.get_conditions()
     assert cond['power'].name == 'power'
     self.assertEqual(cond['power'].keywords, [SearchKeyword(5, 'and', '<'),
                                               SearchKeyword(0, 'and', '>')])
コード例 #6
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_assume_equality_conditional(self):
     parser = ConditionParser({'cmc': '5'})
     cond = parser.get_conditions()
     assert cond['cmc'].name == 'cmc'
     self.assertEqual(cond['cmc'].keywords, [SearchKeyword(5, 'and', '=')])
コード例 #7
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_understand_pipe_as_logical_or(self):
     conditions = ConditionParser({'text': 'destroy|exile'}).get_conditions()
     assert conditions['text'].keywords == [SearchKeyword('destroy', 'or'),
                                            SearchKeyword('exile', 'or')]
コード例 #8
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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})
コード例 #9
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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"]')
コード例 #10
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_group_text_in_brackets(self):
     word = SearchKeyword('trample', 'and')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+[trample]')
コード例 #11
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_treat_space_separated_terms_as_single_phrase(self):
     assert self.keywords[0] == SearchKeyword('first strike', 'and')
コード例 #12
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_accept_complete_words(self):
     parser = ConditionParser({'rarity': 'special'})
     cond = parser.get_conditions()
     self.assertEqual(cond['rarity'].keywords, [SearchKeyword('S', 'and')])
コード例 #13
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_upcase_keyword(self):
     parser = ConditionParser({'rarity': 's'})
     cond = parser.get_conditions()
     self.assertEqual(cond['rarity'].keywords, [SearchKeyword('S', 'and')])
コード例 #14
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_convert_wedge_to_colors(self):
     parser = ConditionParser({'color': 'sultai'})
     cond = parser.get_conditions()
     self.assertEqual(cond['color'].keywords, [SearchKeyword('B', 'and'),
                                               SearchKeyword('G', 'and'),
                                               SearchKeyword('U', 'and')])
コード例 #15
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_convert_shard_to_colors(self):
     parser = ConditionParser({'color': 'grixis'})
     cond = parser.get_conditions()
     self.assertEqual(cond['color'].keywords, [SearchKeyword('B', 'and'),
                                               SearchKeyword('R', 'and'),
                                               SearchKeyword('U', 'and')])
コード例 #16
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_not_quote_rarities(self):
     word = SearchKeyword('M', 'and')
     fl = SearchFilter('rarity', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'rarity=+[M]')
コード例 #17
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_render_not_operator(self):
     word = SearchKeyword('graveyard', 'not')
     fl = SearchFilter('text', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'text=+![graveyard]')
コード例 #18
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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]')
コード例 #19
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_render_greater_than_comparison(self):
     word = SearchKeyword(5, 'and', '>')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+>[5]')
コード例 #20
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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]')
コード例 #21
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_consider_as_separate_keywords(self):
     exile = SearchKeyword('exile', 'and')
     graveyard = SearchKeyword('graveyard', 'and')
     assert self.conditions['text'].keywords == [exile, graveyard]
コード例 #22
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_render_equality_comparison(self):
     word = SearchKeyword(5, 'and', '=')
     fl = SearchFilter('power', keywords=[word])
     self.assertEqual(fl.url_fragment(), 'power=+=[5]')
コード例 #23
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_understand_bang_as_logical_not(self):
     conditions = ConditionParser({'text': 'return,!hand'}).get_conditions()
     assert conditions['text'].keywords == [SearchKeyword('return', 'and'),
                                            SearchKeyword('hand', 'not')]
コード例 #24
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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]')
コード例 #25
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_understand_less_than_conditional(self):
     parser = ConditionParser({'power': '<5'})
     cond = parser.get_conditions()
     assert cond['power'].name == 'power'
     self.assertEqual(cond['power'].keywords, [SearchKeyword(5, 'and', '<')])
コード例 #26
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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])')
コード例 #27
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_understand_greater_than_conditional(self):
     parser = ConditionParser({'tough': '>3'})
     cond = parser.get_conditions()
     self.assertEqual(cond['tough'].keywords, [SearchKeyword(3, 'and', '>')])
コード例 #28
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 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])')
コード例 #29
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_understand_less_than_or_equal_to(self):
     parser = ConditionParser({'tough': '<=3'})
     cond = parser.get_conditions()
     self.assertEqual(cond['tough'].keywords, [SearchKeyword(3, 'and', '<=')])
コード例 #30
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_assume_and_when_adjacent(self):
     parser = ConditionParser({'color': 'wbg'})
     cond = parser.get_conditions()
     self.assertEqual(cond['color'].keywords, [SearchKeyword('W', 'and'),
                                               SearchKeyword('B', 'and'),
                                               SearchKeyword('G', 'and')])