Exemplo n.º 1
0
 def should_assume_equality_conditional(self):
     parser = ConditionParser({'cmc': '5'})
     cond = parser.get_conditions()
     assert cond[0].name == 'cmc'
     self.assertEqual(cond[0].keywords, [SearchKeyword(5, 'and', '=')])
Exemplo n.º 2
0
 def should_accept_complete_words(self):
     parser = ConditionParser({'rarity': 'special'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword('S', 'and')])
Exemplo n.º 3
0
 def setUp(self):
     parser = ConditionParser({'text': 'trample'})
     self.conditions = parser.get_conditions()
Exemplo n.º 4
0
 def should_assume_and_when_comma_separated(self):
     parser = ConditionParser({'color': 'w,u,g'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword('W', 'and'),
                                         SearchKeyword('U', 'and'),
                                         SearchKeyword('G', 'and')])
Exemplo n.º 5
0
 def should_correctly_combine_not_and_and(self):
     parser = ConditionParser({'color': '!b,r'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword('B', 'not'),
                                         SearchKeyword('R', 'and')])
Exemplo n.º 6
0
 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')])
Exemplo n.º 7
0
 def should_raise_error_for_non_numeric_input(self):
     parser = ConditionParser({'tough': 'f'})
     assert_raises(ValueError, parser.get_conditions)
Exemplo n.º 8
0
 def should_raise_error_if_invalid_rarity(self):
     parser = ConditionParser({'rarity': 'd'})
     assert_raises(ValueError, parser.get_conditions)
Exemplo n.º 9
0
 def should_accept_complete_words(self):
     parser = ConditionParser({'rarity': 'special'})
     cond = parser.get_conditions()
     self.assertEqual(cond['rarity'].keywords, [SearchKeyword('S', 'and')])
Exemplo n.º 10
0
 def should_raise_error_for_non_color_input(self):
     parser = ConditionParser({'color': 'd'})
     assert_raises(ValueError, parser.get_conditions)
Exemplo n.º 11
0
 def should_upcase_keyword(self):
     parser = ConditionParser({'rarity': 's'})
     cond = parser.get_conditions()
     self.assertEqual(cond['rarity'].keywords, [SearchKeyword('S', 'and')])
Exemplo n.º 12
0
 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')])
Exemplo n.º 13
0
 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')])
Exemplo n.º 14
0
 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')])
Exemplo n.º 15
0
 def should_understand_multiple_conditionals(self):
     parser = ConditionParser({'power': '<5,>0'})
     cond = parser.get_conditions()
     assert cond[0].name == 'power'
     self.assertEqual(cond[0].keywords, [SearchKeyword(5, 'and', '<'),
                                         SearchKeyword(0, 'and', '>')])
Exemplo n.º 16
0
 def setUp(self):
     parser = ConditionParser({'text': 'first strike'})
     self.keywords = parser.get_conditions()['text'].keywords
Exemplo n.º 17
0
 def should_understand_equality_conditional(self):
     parser = ConditionParser({'tough': '=3'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword(3, 'and', '=')])
Exemplo n.º 18
0
 def setUp(self):
     parser = ConditionParser({'text': 'trample'})
     self.conditions = parser.get_conditions()
Exemplo n.º 19
0
 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', '<=')])
Exemplo n.º 20
0
 def setUp(self):
     parser = ConditionParser({'text': 'exile,graveyard'})
     self.conditions = parser.get_conditions()
Exemplo n.º 21
0
 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')])
Exemplo n.º 22
0
 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')]
Exemplo n.º 23
0
 def should_assume_and_when_adjacent(self):
     parser = ConditionParser({'color': 'wbg'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword('W', 'and'),
                                         SearchKeyword('B', 'and'),
                                         SearchKeyword('G', 'and')])
Exemplo n.º 24
0
 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')]
Exemplo n.º 25
0
 def should_upcase_keyword(self):
     parser = ConditionParser({'rarity': 's'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword('S', 'and')])
Exemplo n.º 26
0
 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', '=')])
Exemplo n.º 27
0
 def setUp(self):
     parser = ConditionParser({'text': 'first strike'})
     self.keywords = parser.get_conditions()[0].keywords
Exemplo n.º 28
0
 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', '<')])
Exemplo n.º 29
0
 def setUp(self):
     parser = ConditionParser({'text': 'exile,graveyard'})
     self.conditions = parser.get_conditions()
Exemplo n.º 30
0
 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', '>')])
Exemplo n.º 31
0
 def should_understand_less_than_conditional(self):
     parser = ConditionParser({'power': '<5'})
     cond = parser.get_conditions()
     assert cond[0].name == 'power'
     self.assertEqual(cond[0].keywords, [SearchKeyword(5, 'and', '<')])
Exemplo n.º 32
0
 def should_understand_greater_than_conditional(self):
     parser = ConditionParser({'tough': '>3'})
     cond = parser.get_conditions()
     self.assertEqual(cond['tough'].keywords, [SearchKeyword(3, 'and', '>')])
Exemplo n.º 33
0
 def should_understand_greater_than_conditional(self):
     parser = ConditionParser({'tough': '>3'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword(3, 'and', '>')])
Exemplo n.º 34
0
 def should_understand_equality_conditional(self):
     parser = ConditionParser({'tough': '=3'})
     cond = parser.get_conditions()
     self.assertEqual(cond['tough'].keywords, [SearchKeyword(3, 'and', '=')])
Exemplo n.º 35
0
 def should_understand_less_than_or_equal_to(self):
     parser = ConditionParser({'tough': '<=3'})
     cond = parser.get_conditions()
     self.assertEqual(cond[0].keywords, [SearchKeyword(3, 'and', '<=')])
Exemplo n.º 36
0
 def should_assume_and_when_comma_separated(self):
     parser = ConditionParser({'color': 'w,u,g'})
     cond = parser.get_conditions()
     self.assertEqual(cond['color'].keywords, [SearchKeyword('W', 'and'),
                                               SearchKeyword('U', 'and'),
                                               SearchKeyword('G', 'and')])