Esempio n. 1
0
    def test_standard_orientation(self,
                                  standard_orientation: Orientation) -> None:
        """Test an Orientation initialized to standard orientation"""
        assert standard_orientation.is_valid()
        assert standard_orientation.is_standard()
        as_standard = standard_orientation.to_standard()
        assert as_standard == standard_orientation
        assert str(standard_orientation) == "Red-♥♦♢♡"
        assert repr(standard_orientation) == (
            "Orientation(Side.RED,"
            " Shape.HEART, End.TAB, Shape.DIAMOND, End.TAB,"
            " Shape.DIAMOND, End.BLANK, Shape.HEART, End.BLANK)")
        assert standard_orientation.side == Side.RED

        assert standard_orientation.north == (Shape.HEART, End.TAB)
        assert standard_orientation.east == (Shape.DIAMOND, End.TAB)
        assert standard_orientation.south == (Shape.DIAMOND, End.BLANK)
        assert standard_orientation.west == (Shape.HEART, End.BLANK)

        assert standard_orientation.north_shape == Shape.HEART
        assert standard_orientation.east_shape == Shape.DIAMOND
        assert standard_orientation.south_shape == Shape.DIAMOND
        assert standard_orientation.west_shape == Shape.HEART

        assert standard_orientation.north_end == End.TAB
        assert standard_orientation.east_end == End.TAB
        assert standard_orientation.south_end == End.BLANK
        assert standard_orientation.west_end == End.BLANK
Esempio n. 2
0
    def test_invalid(self) -> None:
        invalid = Orientation(
            Side.RED,
            Shape.HEART,
            End.TAB,
            Shape.HEART,
            End.TAB,
            Shape.HEART,
            End.TAB,  # Too many tabs
            Shape.HEART,
            End.BLANK,
        )

        assert not invalid.is_valid()
Esempio n. 3
0
    def test_reorientation(self, standard_orientation: Orientation) -> None:
        """Test reorientation."""
        # Turn 90 (clockwise) four times
        rotated = standard_orientation.reorient(turn=Turn.TURN_90)
        assert str(rotated) == "Red-♡♥♦♢"
        rotated = rotated.reorient(turn=Turn.TURN_90)
        assert str(rotated) == "Red-♢♡♥♦"
        rotated = rotated.reorient(turn=Turn.TURN_90)
        assert str(rotated) == "Red-♦♢♡♥"
        rotated = rotated.reorient(turn=Turn.TURN_90)
        assert str(rotated) == "Red-♥♦♢♡"
        assert rotated == standard_orientation

        # Turn 180 twice
        rotated = standard_orientation.reorient(turn=Turn.TURN_180)
        assert str(rotated) == "Red-♢♡♥♦"
        rotated = rotated.reorient(turn=Turn.TURN_180)
        assert str(rotated) == "Red-♥♦♢♡"
        assert rotated == standard_orientation

        # Turn 270 four times
        rotated = standard_orientation.reorient(turn=Turn.TURN_270)
        assert str(rotated) == "Red-♦♢♡♥"
        rotated = rotated.reorient(turn=Turn.TURN_270)
        assert str(rotated) == "Red-♢♡♥♦"
        rotated = rotated.reorient(turn=Turn.TURN_270)
        assert str(rotated) == "Red-♡♥♦♢"
        rotated = rotated.reorient(turn=Turn.TURN_270)
        assert str(rotated) == "Red-♥♦♢♡"
        assert rotated == standard_orientation

        # Flip (Left to Right)
        flipped = standard_orientation.reorient(flip=True)
        assert str(flipped) == "Black-♥♡♢♦"
        flipped = flipped.reorient(flip=True)
        assert str(flipped) == "Red-♥♦♢♡"
        assert flipped == standard_orientation

        # Flip then rotate
        flipped = standard_orientation.reorient(flip=True, turn=Turn.TURN_90)
        assert str(flipped) == "Black-♦♥♡♢"
        flipped = flipped.reorient(flip=True, turn=Turn.TURN_90)
        assert str(flipped) == "Red-♥♦♢♡"
        assert flipped == standard_orientation
Esempio n. 4
0
 def test_flipped(self, standard_orientation: Orientation) -> None:
     """Test an Orientation flipped from standard orientation"""
     orient = standard_orientation.reorient(flip=True)
     assert orient.is_valid()
     assert not orient.is_standard()
     standard = orient.to_standard()
     assert standard != orient
     rotated = orient.reorient(flip=True)
     assert standard == rotated
     assert str(orient) == "Black-♥♡♢♦"
Esempio n. 5
0
 def test_rotated_90(self, standard_orientation: Orientation) -> None:
     """Test an Orientation rotated 90 from standard orientation"""
     orient = standard_orientation.reorient(turn=Turn.TURN_90)
     assert orient.is_valid()
     assert not orient.is_standard()
     standard = orient.to_standard()
     assert standard != orient
     rotated = orient.reorient(turn=Turn.TURN_270)
     assert standard == rotated
     assert str(orient) == "Red-♡♥♦♢"
Esempio n. 6
0
    def test_fits(self, all_clubs: Orientation,
                  all_hearts: Orientation) -> None:
        assert all_clubs.fits_right(all_clubs)
        assert not all_clubs.fits_right(all_hearts)

        assert all_clubs.fits_right(all_clubs)
        assert not all_clubs.fits_right(all_hearts)

        assert all_clubs.fits_above(all_clubs)
        assert not all_clubs.fits_above(all_hearts)

        assert all_clubs.fits_below(all_clubs)
        assert not all_clubs.fits_below(all_hearts)
Esempio n. 7
0
def all_hearts() -> Orientation:
    return Orientation(
        Side.RED,
        Shape.HEART,
        End.TAB,
        Shape.HEART,
        End.TAB,
        Shape.HEART,
        End.BLANK,
        Shape.HEART,
        End.BLANK,
    )
Esempio n. 8
0
def all_clubs() -> Orientation:
    return Orientation(
        Side.RED,
        Shape.CLUB,
        End.TAB,
        Shape.CLUB,
        End.TAB,
        Shape.CLUB,
        End.BLANK,
        Shape.CLUB,
        End.BLANK,
    )
Esempio n. 9
0
def standard_orientation() -> Orientation:
    return Orientation(
        Side.RED,
        Shape.HEART,
        End.TAB,
        Shape.DIAMOND,
        End.TAB,
        Shape.DIAMOND,
        End.BLANK,
        Shape.HEART,
        End.BLANK,
    )