Example #1
0
 def test_empty_sub_ranges(self):
     sub_ranges = [
         'MS+',
         None,
         'BS+'
     ]
     pf_range = PostflopRange("With None", sub_ranges)
     self.assertEqual(pf_range.r_3, 'BS+')
     self.assertEqual(pf_range.r_2, None)
     pf_range.check_sub_ranges()
     self.assertEqual(pf_range.has_error, False)
Example #2
0
 def test_check_sub_ranges(self):
     sub_ranges = [
         'MS+',
         '2PH+'
     ]
     pf_range = PostflopRange("Wrong", sub_ranges)
     self.assertEqual(pf_range.has_error, False)
     pf_range.check_sub_ranges(print_error=False)
     self.assertEqual(pf_range.has_error, True)
     self.assertEqual(pf_range._errors[0], None)
     self.assertEqual(pf_range._errors[1].easy_range, "2PH+")
     self.assertEqual(pf_range._errors[1].column, 3)
Example #3
0
 def test_postflop_range_with_parent_descriptions(self):
     range_group = RangeGroup("vs pfr", descriptions=['raise', 'call'])
     sub_ranges = [
         'MS+',
         '2P+'
     ]
     pf_range = PostflopRange("Tight", sub_ranges=sub_ranges, parent=range_group)
     self.assertEqual(pf_range.sub_ranges[1], '2P+')
     self.assertEqual(pf_range.descriptions, ['raise', 'call'])
     self.assertEqual(pf_range.call, '2P+')
Example #4
0
 def test_postflop_range(self):
     sub_ranges = [
         'MS+',
         '2P+'
     ]
     pf_range = PostflopRange("Tight", sub_ranges=sub_ranges)
     self.assertEqual(pf_range.name, "Tight")
     self.assertEqual(pf_range.sub_ranges[1], '2P+')
     self.assertEqual(pf_range.descriptions, ['r_1', 'r_2'])
     self.assertEqual(pf_range.r_2, '2P+')
Example #5
0
 def test_postflop_range_with_descriptions(self):
     range_group = RangeGroup("vs pfr", descriptions=['raise', 'call'])
     sub_ranges = [
         'MS+',
         '2P+'
     ]
     pf_range = PostflopRange(name="Range",
                              sub_ranges=sub_ranges,
                              parent=range_group,
                              descriptions=['pum', 'bum'])
     self.assertEqual(pf_range.sub_ranges[1], '2P+')
     self.assertEqual(pf_range.descriptions, ['pum', 'bum'])
     self.assertEqual(pf_range.bum, '2P+')
Example #6
0
 def test_to_json_with_sub_ranges(self):
     pr_dict_expected = {'name': 'parent',
                         'ranges': [
                             {'name': 'child1',
                              'ranges': [
                                  {'name': 'Tight',
                                   'sub_ranges': ['TS, TP+']},
                                  {'name': 'Loose',
                                   'sub_ranges': ['TP+, BP+']},
                              ]},
                             {'name': 'child2',
                              'ranges': []},
                         ],
                         }
     pr = RangeGroup(name="parent")
     child1 = RangeGroup(name="child1")
     child1.add_child(PostflopRange('Tight', ['TS, TP+']))
     child1.add_child(PostflopRange('Loose', ['TP+, BP+']))
     pr.add_child(child1)
     pr.add_child(RangeGroup(name="child2"))
     pr_dict = json.loads(json.dumps(pr, default=_json_default))
     self.assertEqual(pr_dict, pr_dict_expected)
Example #7
0
 def test_check_sub_ranges(self):
     descriptions = [
         'raise',
         'call',
         'bluff raise',
         'fold',
     ]
     sub_ranges = [
         'MS+',
         'PUPA-',
         'GS+',
         'PINYA',
     ]
     parent1 = RangeGroup('Dry board', descriptions=descriptions)
     child = RangeGroup('Low board', parent=parent1)
     tight = PostflopRange('Tight', sub_ranges=sub_ranges, parent=child)
     self.assertEqual(tight.has_error, False)
     self.assertEqual(child.has_error, False)
     self.assertEqual(parent1.has_error, False)
     parent1.check_sub_ranges(print_error=False)
     self.assertEqual(tight.has_error, True)
     self.assertEqual(child.has_error, True)
     self.assertEqual(parent1.has_error, True)
Example #8
0
 def test_check_load_and_check(self):
     descriptions = [
         'raise',
         'call',
         'bluff raise',
         'fold',
     ]
     sub_ranges = [
         'MS+',
         'PUPA-',
         'GS+',
         'PINYA',
     ]
     parent1 = RangeGroup('Dry board', descriptions=descriptions)
     child = RangeGroup('Low board', parent=parent1)
     tight = PostflopRange('Tight', sub_ranges=sub_ranges, parent=child)
     self.assertEqual(tight.has_error, False)
     self.assertEqual(child.has_error, False)
     self.assertEqual(parent1.has_error, False)
     parent1.save('ranges_with_error.json')
     new_parent = RangeGroup.load_and_check('ranges_with_error.json', print_error=False)
     self.assertEqual(new_parent.has_error, True)
     self.assertEqual(new_parent.children[0].has_error, True)
     self.assertEqual(new_parent.children[0].children[0].has_error, True)