Esempio n. 1
0
def make_mrec_2():
    items = [
        (
            ((0, 0), ),
            DetailedGame("100111",
                         left_wingame=True,
                         left_opener=True,
                         tiebreak=False),
        ),
        (
            ((1, 0), ),
            DetailedGame("011000",
                         left_wingame=True,
                         left_opener=False,
                         tiebreak=False),
        ),
    ]
    ds = DetailedScore(items, retired=False)
    scr = Score.from_pairs(ds.final_score(), retired=False)
    return dbsa.MatchRec(
        date=datetime.date(2020, 6, 26),
        tour_id=101,
        rnd=Round("Final"),
        left_id=555,
        right_id=333,
        detailed_score=ds,
        score=scr,
    )
Esempio n. 2
0
    def test_tiebreaks(self):
        dg = DetailedGame(
            "0000000", left_wingame=False, left_opener=True, tiebreak=True
        )
        self.assertEqual([], list(detailed_game_miss_points(dg)))

        dg = DetailedGame(
            "11111101", left_wingame=True, left_opener=True, tiebreak=True
        )
        mp = MissPoint(
            GamePointEvent(left_side=True, left_serve=False, tiebreak=True, multier=6),
            revenged=co.GAME,
        )
        self.assertEqual([mp], list(detailed_game_miss_points(dg)))

        dg = DetailedGame(
            "111111001", left_wingame=True, left_opener=True, tiebreak=True
        )
        mp = MissPoint(
            GamePointEvent(left_side=True, left_serve=False, tiebreak=True, multier=6),
            revenged=co.GAME,
        )
        mp2 = MissPoint(
            GamePointEvent(left_side=True, left_serve=True, tiebreak=True, multier=5),
            revenged=co.GAME,
        )
        self.assertEqual([mp, mp2], list(detailed_game_miss_points(dg)))
    def test_leadchanges_count(self):
        det_game = DetailedGame("01100110111",
                                left_wingame=True,
                                left_opener=True,
                                tiebreak=True)
        leadchanges_count = tie_leadchanges_count(det_game)
        self.assertEqual(leadchanges_count, 3)

        det_game = DetailedGame("01100110111",
                                left_wingame=False,
                                left_opener=False,
                                tiebreak=True)
        leadchanges_count = tie_leadchanges_count(det_game)
        self.assertEqual(leadchanges_count, 3)

        det_game = DetailedGame("0000000",
                                left_wingame=False,
                                left_opener=True,
                                tiebreak=True)
        leadchanges_count = tie_leadchanges_count(det_game)
        self.assertEqual(leadchanges_count, 0)

        det_game = DetailedGame("01111111",
                                left_wingame=True,
                                left_opener=True,
                                tiebreak=True)
        leadchanges_count = tie_leadchanges_count(det_game)
        self.assertEqual(leadchanges_count, 1)
 def test_save_restore(self):
     det_game = DetailedGame(
         "0110011011",
         left_wingame=True,
         left_opener=True,
         tiebreak=False,
         error=error_code("SPANING"),
     )
     text = str(det_game)
     det_game2 = DetailedGame.from_str(text)
     self.assertEqual(det_game, det_game2)
 def test_save_restore2(self):
     det_game = DetailedGame(
         "000001111111111",
         left_wingame=True,
         left_opener=True,
         tiebreak=True,
         supertiebreak=True,
         error=0,
     )
     text = str(det_game)
     det_game2 = DetailedGame.from_str(text)
     self.assertEqual(det_game, det_game2)
     self.assertEqual(15, len(list(iter(det_game2))))
 def test_point_text_score_tie(self):
     pts = "100110011100100111"
     det_game = DetailedGame(points=pts,
                             left_wingame=True,
                             left_opener=True,
                             tiebreak=True)
     points = [p for p in det_game]
     self.assertEqual(points[0].text_score(), ("0", "0"))
     self.assertEqual(points[1].text_score(), ("1", "0"))
     self.assertEqual(points[2].text_score(), ("1", "1"))
     self.assertEqual(points[3].text_score(), ("1", "2"))
     self.assertEqual(points[4].text_score(), ("2", "2"))
     self.assertEqual(points[5].text_score(), ("3", "2"))
     self.assertEqual(points[6].text_score(), ("3", "3"))
     self.assertEqual(points[7].text_score(), ("3", "4"))
     self.assertEqual(points[8].text_score(), ("4", "4"))
     self.assertEqual(points[9].text_score(), ("5", "4"))
     self.assertEqual(points[10].text_score(), ("6", "4"))
     self.assertEqual(points[11].text_score(), ("6", "5"))
     self.assertEqual(points[12].text_score(), ("6", "6"))
     self.assertEqual(points[13].text_score(), ("7", "6"))
     self.assertEqual(points[14].text_score(), ("7", "7"))
     self.assertEqual(points[15].text_score(), ("7", "8"))
     self.assertEqual(points[16].text_score(), ("8", "8"))
     self.assertEqual(points[17].text_score(), ("9", "8"))
     self.assertEqual(points[17].text_score(left=True), ("9", "8"))
     self.assertEqual(points[17].text_score(left=False), ("8", "9"))
     self.assertEqual(len(points), 18)
 def test_minibreaks_count(self):
     det_game = DetailedGame("01100110111",
                             left_wingame=True,
                             left_opener=True,
                             tiebreak=True)
     minibreaks_count = tie_minibreaks_count(det_game)
     self.assertEqual(minibreaks_count, 10)
def make_detailed_game(opener_side, game_winside, num_pairs, tiebreak, is_super_tie):
    """opener_side - who serve at usial game, or who begin in tiebreak"""

    def distances(prev_pair, pair, unit=1 if tiebreak else 15):
        left_dist = (pair[0] - prev_pair[0]) // unit
        right_dist = (pair[1] - prev_pair[1]) // unit
        return left_dist, right_dist

    def is_opener_win_point(prev_pair, pair):
        left_dist, right_dist = distances(prev_pair, pair)
        if opener_side.is_left():
            return left_dist > right_dist
        elif opener_side.is_right():
            return right_dist > left_dist
        raise co.TennisScoreError(
            "bad pts seq in make_detailed_game {} {}".format(prev_pair, pair)
        )

    prev_pair = (0, 0)
    points = ""
    for pair in num_pairs:
        points += str(int(is_opener_win_point(prev_pair, pair)))
        prev_pair = pair
    if not tiebreak:
        if opener_side == game_winside:
            points += "1"
        else:
            points += "0"
    return DetailedGame(
        points,
        left_wingame=game_winside.is_left(),
        left_opener=opener_side.is_left(),
        tiebreak=tiebreak,
        supertiebreak=is_super_tie,
    )
 def test_state(self):
     """here error_code value is not meaning and used for test get/set"""
     det_game = DetailedGame(
         "0110011011",
         left_wingame=True,
         left_opener=True,
         tiebreak=False,
         error=error_code("GAME_ORIENT"),
     )
     self.assertTrue(det_game.error)
     self.assertTrue(det_game.left_wingame)
     self.assertTrue(det_game.left_opener)
     self.assertFalse(det_game.tiebreak)
     self.assertEqual(det_game.error, error_code("GAME_ORIENT"))
     det_game.error = 0
     det_game.left_wingame = False
     det_game.left_opener = False
     det_game.tiebreak = True
     self.assertFalse(det_game.error)
     self.assertFalse(det_game.left_wingame)
     self.assertFalse(det_game.left_opener)
     self.assertTrue(det_game.tiebreak)
     det_game.error = error_code("GAME_ORIENT")
     self.assertTrue(det_game.error)
     self.assertEqual(det_game.error, error_code("GAME_ORIENT"))
     self.assertFalse(det_game.left_wingame)
     self.assertFalse(det_game.left_opener)
     self.assertTrue(det_game.tiebreak)
 def test_enumerate_tie_2(self):
     det_game = DetailedGame("1111111",
                             left_wingame=False,
                             left_opener=False,
                             tiebreak=True)
     pnts = list(iter(det_game))
     self.assertEqual(pnts[0].num_score(before=False), (1, 0))
     self.assertEqual(pnts[1].num_score(before=False), (2, 0))
     self.assertEqual(pnts[-1].num_score(before=False), (7, 0))
    def test_points_text_score(self):
        det_game = DetailedGame("01100110100111",
                                left_wingame=True,
                                left_opener=True,
                                tiebreak=False)
        points_0_0 = list(det_game.points_text_score(("0", "0")))
        self.assertEqual(points_0_0[0].text_score(), ("0", "0"))
        self.assertEqual(1, len(points_0_0))

        points_40_40 = list(det_game.points_text_score(("40", "40")))
        self.assertEqual(4, len(points_40_40))
        for pnt in points_40_40:
            self.assertEqual(pnt.text_score(), ("40", "40"))

        points_a_40 = list(det_game.points_text_score(("A", "40")))
        self.assertEqual(3, len(points_a_40))
        for pnt in points_a_40:
            self.assertEqual(pnt.text_score(), ("A", "40"))
 def test_enumerate_tie(self):
     det_game = DetailedGame("0001111111",
                             left_wingame=False,
                             left_opener=False,
                             tiebreak=True)
     pnts = list(iter(det_game))
     self.assertEqual(pnts[0].num_score(before=False), (0, 1))
     self.assertEqual(pnts[1].num_score(before=False), (0, 2))
     self.assertEqual(pnts[2].num_score(before=False), (0, 3))
     self.assertEqual(pnts[3].num_score(before=False), (1, 3))
     self.assertEqual(pnts[-1].num_score(before=False), (7, 3))
Esempio n. 13
0
    def test_2(self):
        dg = DetailedGame(
            "11010011", left_wingame=True, left_opener=True, tiebreak=False
        )
        mp = MissPoint(
            GamePointEvent(left_side=True, left_serve=True, tiebreak=False, multier=2),
            revenged=co.GAME,
        )
        mp2 = MissPoint(
            GamePointEvent(left_side=True, left_serve=True, tiebreak=False, multier=1),
            revenged=co.GAME,
        )
        self.assertEqual([mp, mp2], list(detailed_game_miss_points(dg)))

        dg = DetailedGame(
            "1101000111", left_wingame=True, left_opener=True, tiebreak=False
        )
        mp3r = MissPoint(
            GamePointEvent(left_side=False, left_serve=True, tiebreak=False, multier=1),
            revenged=None,
        )
        self.assertEqual([mp, mp2, mp3r], list(detailed_game_miss_points(dg)))
 def test_left_break_point_score(self):
     det_game = DetailedGame("00011100",
                             left_wingame=False,
                             left_opener=True,
                             tiebreak=False)
     points = [p for p in det_game]
     self.assertEqual(points[0].break_point_score(left=True), 0)
     self.assertEqual(points[1].break_point_score(left=True), 0)
     self.assertEqual(points[2].break_point_score(left=True), 0)
     self.assertEqual(points[3].break_point_score(left=True), 3)
     self.assertEqual(points[4].break_point_score(left=True), 2)
     self.assertEqual(points[5].break_point_score(left=True), 1)
     self.assertEqual(points[6].break_point_score(left=True), 0)
     self.assertEqual(points[7].break_point_score(left=True), 1)
    def test_minibreaks_diff(self):
        det_game = DetailedGame("01100110111",
                                left_wingame=True,
                                left_opener=True,
                                tiebreak=True)
        points = [p for p in det_game]
        self.assertEqual(points[0].minibreaks_diff(), -1)
        self.assertEqual(points[0].minibreaks_diff(left=False), 1)

        self.assertEqual(points[1].minibreaks_diff(), 0)
        self.assertEqual(points[1].minibreaks_diff(left=False), 0)

        self.assertEqual(points[2].minibreaks_diff(), 1)
        self.assertEqual(points[2].minibreaks_diff(left=False), -1)
    def test_few_points(self):
        pts = "1"
        det_game = DetailedGame(
            points=pts,
            left_wingame=True,
            left_opener=True,
            tiebreak=False,
            error=error_code("POINT_SCORE_FEW_DATA"),
        )
        points = [p for p in det_game]
        self.assertEqual(len(points), 1)
        self.assertEqual(points[0].win(), True)

        pts = ""
        det_game = DetailedGame(
            points=pts,
            left_wingame=True,
            left_opener=True,
            tiebreak=False,
            error=error_code("POINT_SCORE_FEW_DATA"),
        )
        points = [p for p in det_game]
        self.assertEqual(len(points), 0)
 def test_save_restore2(self):
     items = [
         (
             ((0, 0), ),
             DetailedGame("1111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((1, 0), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
     ]
     ds = DetailedScore(items, retired=True)
     ds.error = error_code("SET5_SCORE_PROBLEMS") | error_code(
         "SET4_SCORE_PROBLEMS")
     text = ds.tostring()
     ds2 = DetailedScore.from_str(text)
     self.assertEqual(ds, ds2)
    def test_set_items(self):
        ds = DetailedScoreTest.make_2set_det_score()
        self.assertEqual(match_win_side(ds), co.RIGHT)
        set_items = list(ds.set_items(setnum=2))
        self.assertEqual(len(set_items), 6)

        beg_item = set_items[0]
        self.assertEqual(
            beg_item[0],
            (
                (6, 7),
                (0, 0),
            ),
        )
        self.assertEqual(
            beg_item[1],
            DetailedGame("1111",
                         left_wingame=False,
                         left_opener=False,
                         tiebreak=False),
        )

        end_item = set_items[-1]
        self.assertEqual(
            end_item[0],
            (
                (6, 7),
                (0, 5),
            ),
        )
        self.assertEqual(
            end_item[1],
            DetailedGame("01000",
                         left_wingame=False,
                         left_opener=True,
                         tiebreak=False),
        )
 def test_enumerate(self):
     det_game = DetailedGame("001101010111",
                             left_wingame=True,
                             left_opener=True,
                             tiebreak=False)
     pnts = list(iter(det_game))
     self.assertEqual(pnts[0].num_score(before=False), (0, 1))
     self.assertEqual(pnts[1].num_score(before=False), (0, 2))
     self.assertEqual(pnts[2].num_score(before=False), (1, 2))
     self.assertEqual(pnts[3].num_score(before=False), (2, 2))
     self.assertEqual(pnts[4].num_score(before=False), (2, 3))
     self.assertEqual(pnts[5].num_score(before=False), (3, 3))
     self.assertEqual(pnts[6].num_score(before=False), (3, 4))
     self.assertEqual(pnts[7].num_score(before=False), (4, 4))
     self.assertEqual(pnts[8].num_score(before=False), (4, 5))
     self.assertEqual(pnts[9].num_score(before=False), (5, 5))
     self.assertEqual(pnts[10].num_score(before=False), (6, 5))
     self.assertEqual(pnts[11].num_score(before=False), (7, 5))
 def test_tie_points_iter(self):
     pts = "100110011100100111"
     det_game = DetailedGame(points=pts,
                             left_wingame=True,
                             left_opener=True,
                             tiebreak=True)
     points = [p for p in det_game]
     self.assertEqual(len(points), len(pts))
     self.assertTrue(points[-1].win_game() and points[-1].win())
     self.assertTrue(points[-2].game_point_score(before=False)
                     and points[-2].win())
     self.assertTrue(points[-3].equal_score(before=False)
                     and points[-3].win())
     self.assertTrue(points[-4].equal_score(before=True))
     self.assertTrue(points[-4].break_point_score(before=False)
                     and points[-4].loss())
     self.assertTrue(points[-5].equal_score(before=False)
                     and points[-5].loss())
     self.assertTrue(points[-6].game_point_score(before=False))
     self.assertTrue(points[-7].equal_score(before=False))
     self.assertEqual(
         len([p for p in points if p.equal_score(before=False)]), 3)
     self.assertEqual(len([p for p in points if p.game_point_score()]), 4)
     self.assertEqual(
         len([p for p in points if p.break_point_score(before=False)]), 1)
     # win_minibreak():
     self.assertTrue(points[9].win() and not points[9].serve()
                     and points[9].win_minibreak(True)
                     and points[9].loss_minibreak(False))
     # serve:
     self.assertTrue(points[0].serve(True) and points[0].win(True)
                     and not points[0].win_minibreak(True))
     self.assertTrue(not points[1].serve(True) and points[1].loss(True)
                     and not points[1].win_minibreak(True))
     self.assertTrue(not points[2].serve(True) and points[2].loss(True)
                     and not points[2].win_minibreak(True))
     self.assertTrue(points[3].serve() and points[3].serve(True)
                     and not points[3].serve(False))
     self.assertTrue(points[4].serve() and points[4].serve(True)
                     and not points[4].serve(False))
     self.assertTrue(not points[5].serve() and not points[5].serve(True)
                     and points[5].serve(False))
 def test_point_text_score(self):
     det_game = DetailedGame("01100110100111",
                             left_wingame=True,
                             left_opener=True,
                             tiebreak=False)
     points = [p for p in det_game]
     self.assertEqual(points[0].text_score(), ("0", "0"))
     self.assertEqual(points[1].text_score(), ("0", "15"))
     self.assertEqual(points[2].text_score(), ("15", "15"))
     self.assertEqual(points[3].text_score(), ("30", "15"))
     self.assertEqual(points[4].text_score(), ("30", "30"))
     self.assertEqual(points[5].text_score(), ("30", "40"))
     self.assertEqual(points[6].text_score(), ("40", "40"))
     self.assertEqual(points[7].text_score(), ("A", "40"))
     self.assertEqual(points[8].text_score(), ("40", "40"))
     self.assertEqual(points[9].text_score(), ("A", "40"))
     self.assertEqual(points[10].text_score(), ("40", "40"))
     self.assertEqual(points[11].text_score(), ("40", "A"))
     self.assertEqual(points[12].text_score(), ("40", "40"))
     self.assertEqual(points[13].text_score(), ("A", "40"))
     self.assertEqual(points[13].text_score(left=True), ("A", "40"))
     self.assertEqual(points[13].text_score(left=False), ("40", "A"))
Esempio n. 22
0
 def oneset_dscore_mdict():
     ds = DetailedScore()
     mdict = OrderedDict()
     ds[((4, 4),)] = DetailedGame(
         "1111", left_wingame=True, left_opener=True, tiebreak=False
     )
     ds[((5, 4),)] = DetailedGame(
         "10001111", left_wingame=False, left_opener=False, tiebreak=False
     )
     mdict[((5, 4),)] = [
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=2
             ),
             revenged=co.SET,
             scope=co.SET,
         ),
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=1
             ),
             revenged=co.SET,
             scope=co.SET,
         ),
     ]
     ds[((5, 5),)] = DetailedGame(
         "11101", left_wingame=True, left_opener=True, tiebreak=False
     )
     mdict[((5, 5),)] = [
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=True, tiebreak=False, multier=3
             ),
             revenged=co.GAME,
         )
     ]
     ds[((6, 5),)] = DetailedGame(
         "00011111", left_wingame=False, left_opener=False, tiebreak=False
     )
     mdict[((6, 5),)] = [
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=3
             ),
             revenged=co.SET,
             scope=co.SET,
         ),
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=2
             ),
             revenged=co.SET,
             scope=co.SET,
         ),
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=1
             ),
             revenged=co.SET,
             scope=co.SET,
         ),
     ]
     ds[((6, 6),)] = DetailedGame(
         "1111111", left_wingame=True, left_opener=True, tiebreak=True
     )
     return ds, mdict
Esempio n. 23
0
 def twosets_dscore_mdict():
     ds, mdict = MakeMissDictTest.oneset_dscore_mdict()
     ds[((7, 6), (0, 0))] = DetailedGame(
         "1111", left_wingame=True, left_opener=True, tiebreak=False
     )
     ds[((7, 6), (1, 0))] = DetailedGame(
         "1111", left_wingame=False, left_opener=False, tiebreak=False
     )
     ds[((7, 6), (1, 1))] = DetailedGame(
         "01111", left_wingame=True, left_opener=True, tiebreak=False
     )
     ds[((7, 6), (2, 1))] = DetailedGame(
         "001111", left_wingame=False, left_opener=False, tiebreak=False
     )
     ds[((7, 6), (2, 2))] = DetailedGame(
         "110000", left_wingame=False, left_opener=True, tiebreak=False
     )
     ds[((7, 6), (2, 3))] = DetailedGame(
         "00011111", left_wingame=False, left_opener=False, tiebreak=False
     )
     mdict[((7, 6), (2, 3))] = [
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=3
             ),
             revenged=None,
         ),
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=2
             ),
             revenged=None,
         ),
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=1
             ),
             revenged=None,
         ),
     ]
     ds[((7, 6), (2, 4))] = DetailedGame(
         "110000", left_wingame=False, left_opener=True, tiebreak=False
     )
     ds[((7, 6), (2, 5))] = DetailedGame(
         "0011000", left_wingame=True, left_opener=False, tiebreak=False
     )
     ds[((7, 6), (3, 5))] = DetailedGame(
         "11000111", left_wingame=True, left_opener=True, tiebreak=False
     )
     mdict[((7, 6), (3, 5))] = [
         MissPoint(
             GamePointEvent(
                 left_side=False, left_serve=True, tiebreak=False, multier=1
             ),
             revenged=None,
             scope=co.SET,
         )
     ]
     ds[((7, 6), (4, 5))] = DetailedGame(
         "10000", left_wingame=True, left_opener=False, tiebreak=False
     )
     ds[((7, 6), (5, 5))] = DetailedGame(
         "1111", left_wingame=True, left_opener=True, tiebreak=False
     )
     ds[((7, 6), (6, 5))] = DetailedGame(
         "10001111", left_wingame=False, left_opener=False, tiebreak=False
     )
     mdict[((7, 6), (6, 5))] = [
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=2
             ),
             revenged=co.SET,
             scope=co.MATCH,
         ),
         MissPoint(
             GamePointEvent(
                 left_side=True, left_serve=False, tiebreak=False, multier=1
             ),
             revenged=co.SET,
             scope=co.MATCH,
         ),
     ]
     ds[((7, 6), (6, 6))] = DetailedGame(
         "1111111", left_wingame=True, left_opener=True, tiebreak=True
     )
     return ds, mdict
 def make_2set_det_score_badend():
     items = [
         (
             ((0, 0), ),
             DetailedGame("1111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((1, 0), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((2, 0), ),
             DetailedGame("1111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((3, 0), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 0), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 1), ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 2), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 3), ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 4), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 5), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((5, 5), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((5, 6), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((6, 6), ),
             DetailedGame("0000000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=True),
         ),
         (
             (
                 (6, 7),
                 (0, 0),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 1),
             ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 2),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 3),
             ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 4),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
     ]
     return DetailedScore(items)
 def test_final_num_score(self):
     dg = DetailedGame.from_str("wot_E32768PLWLWL11011")
     fin_num_scr = dg.final_num_score(before=False)
     self.assertEqual(fin_num_scr, (6, 4))
     fin_num_scr = dg.final_num_score(before=True)
     self.assertEqual(fin_num_scr, (5, 4))
 def make_2set_det_score():
     """:return DetailedScore for 6-7(0) 0-6 where match left_opener"""
     items = [
         (
             ((0, 0), ),
             DetailedGame("1111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((1, 0), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((2, 0), ),
             DetailedGame("1111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((3, 0), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 0), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 1), ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 2), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 3), ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 4), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 5), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((5, 5), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((5, 6), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((6, 6), ),
             DetailedGame("0000000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=True),
         ),
         (
             (
                 (6, 7),
                 (0, 0),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 1),
             ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 2),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 3),
             ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 4),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (6, 7),
                 (0, 5),
             ),
             DetailedGame("01000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
     ]
     return DetailedScore(items)
    def test_game_orient_error(self):
        """д.б. ошибка"""
        det_game = DetailedGame("010110110000",
                                left_wingame=True,
                                left_opener=True,
                                tiebreak=True)
        self.assertTrue(det_game.error)
        self.assertTrue(det_game.orientation_error())

        det_game = DetailedGame("010110",
                                left_wingame=True,
                                left_opener=True,
                                tiebreak=True)
        self.assertTrue(det_game.error)
        self.assertTrue(det_game.orientation_error())

        det_game = DetailedGame("001111",
                                left_wingame=False,
                                left_opener=True,
                                tiebreak=False)
        self.assertTrue(det_game.error)
        self.assertTrue(det_game.orientation_error())

        det_game = DetailedGame("110000",
                                left_wingame=True,
                                left_opener=True,
                                tiebreak=False)
        self.assertTrue(det_game.error)
        self.assertTrue(det_game.orientation_error())
 def make_3set_det_score_decsupertie():
     """return DetailedScore variant for Score("7-6 0-6 10-3", decsupertie=True)"""
     items = [
         (
             ((0, 0), ),
             DetailedGame("1111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((1, 0), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((2, 0), ),
             DetailedGame("1111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((3, 0), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 0), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 1), ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 2), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 3), ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((4, 4), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((4, 5), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((5, 5), ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             ((5, 6), ),
             DetailedGame("0000",
                          left_wingame=True,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             ((6, 6), ),
             DetailedGame("1111111",
                          left_wingame=True,
                          left_opener=True,
                          tiebreak=True),
         ),
         (
             (
                 (7, 6),
                 (0, 0),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (7, 6),
                 (0, 1),
             ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             (
                 (7, 6),
                 (0, 2),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (7, 6),
                 (0, 3),
             ),
             DetailedGame("0000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             (
                 (7, 6),
                 (0, 4),
             ),
             DetailedGame("1111",
                          left_wingame=False,
                          left_opener=False,
                          tiebreak=False),
         ),
         (
             (
                 (7, 6),
                 (0, 5),
             ),
             DetailedGame("01000",
                          left_wingame=False,
                          left_opener=True,
                          tiebreak=False),
         ),
         (
             (
                 (7, 6),
                 (0, 6),
                 (0, 0),
             ),
             DetailedGame(
                 "1110000000000",
                 left_wingame=True,
                 left_opener=False,
                 tiebreak=True,
                 supertiebreak=True,
             ),
         ),
     ]
     return DetailedScore(items)