예제 #1
0
    def test_invalid_set_add(self):
        m = Meld(Card(rank=Rank.TWO, suit=Suit.HEART),
                 Card(rank=Rank.TWO, suit=Suit.DIAMOND))
        self.assertTrue(m.all_same_rank)
        self.assertFalse(m.all_same_suit)
        self.assertFalse(m.is_run)
        self.assertFalse(m.is_set)
        self.assertFalse(m.complete)
        self.assertEqual(m.size(), 2)

        with self.assertRaises(InvalidMeldError):
            m.add(Card(rank=Rank.THREE, suit=Suit.CLUB))

        self.assertEqual(m.size(), 2)
예제 #2
0
 def test_invalid_meld_init(self):
     m = Meld()
     with self.assertRaises(InvalidMeldError):
         m = Meld(Card(rank=Rank.TWO, suit=Suit.HEART),
                  Card(rank=Rank.SIX, suit=Suit.CLUB))
     self.assertFalse(m.all_same_rank)
     self.assertFalse(m.all_same_suit)
     self.assertFalse(m.is_run)
     self.assertFalse(m.is_set)
     self.assertFalse(m.complete)
     self.assertEqual(m.size(), 0)  # failed init should have emptied meld
예제 #3
0
    def test_large_valid_run_grows_to_inside_straight(self):
        """A run becomes incomplete after inside straight conversion."""
        m = Meld(Card(rank=Rank.TWO, suit=Suit.HEART),
                 Card(rank=Rank.THREE, suit=Suit.HEART),
                 Card(rank=Rank.FOUR, suit=Suit.HEART))
        self.assertTrue(m.all_same_suit)
        self.assertFalse(m.all_same_rank)
        self.assertTrue(m.is_run)
        self.assertFalse(m.is_set)
        self.assertTrue(m.complete)

        m.add(Card(rank=Rank.SIX, suit=Suit.HEART))

        self.assertEqual(m.size(), 4)
        self.assertTrue(m.all_same_suit)
        self.assertFalse(m.all_same_rank)
        self.assertFalse(m.is_run)
        self.assertFalse(m.is_set)
        self.assertFalse(m.complete)
예제 #4
0
    def test_invalid_add_does_not_break_complete_run(self):
        """A bad addition to a complete run doesn't break it."""
        m = Meld(Card(rank=Rank.TWO, suit=Suit.HEART),
                 Card(rank=Rank.THREE, suit=Suit.HEART),
                 Card(rank=Rank.FOUR, suit=Suit.HEART))
        self.assertTrue(m.all_same_suit)
        self.assertFalse(m.all_same_rank)
        self.assertTrue(m.is_run)
        self.assertFalse(m.is_set)
        self.assertTrue(m.complete)

        with self.assertRaises(InvalidMeldError):
            m.add(Card(rank=Rank.SIX, suit=Suit.CLUB))

        self.assertEqual(m.size(), 3)
        self.assertTrue(m.all_same_suit)
        self.assertFalse(m.all_same_rank)
        self.assertTrue(m.is_run)
        self.assertFalse(m.is_set)
        self.assertTrue(m.complete)