Exemplo n.º 1
0
 def test_no_property(self):
     """Push text with no associated behaviour dictionary"""
     for text in TEXT:
         pile = sp("{}.".format(text))
         behaviour = {"t": {}}
     with self.assertRaises(KeyError):
         attempt_to_move(pile, behaviour)
Exemplo n.º 2
0
 def test_no_property(self):
     """Push entity with no property in the behaviour dictionary"""
     for entity in ENTITIES:
         pile = sp("{}.".format(entity))
         behaviour = {"{}".format(entity.lower): {}}
         with self.assertRaises(KeyError):
             attempt_to_move(pile, behaviour)
Exemplo n.º 3
0
 def test_no_behaviour(self):
     """Push text with no associated behaviour dictionary"""
     for text in TEXT:
         pile = sp("{}.".format(text))
         with self.subTest(text):
             with self.assertRaises(KeyError):
                 attempt_to_move(pile, {})
Exemplo n.º 4
0
 def test_simple_stuck(self):
     """Simple cases of UnableToMove exception"""
     piles = map(
         sp,
         ("", "R", "RR", "RRR", "W", "RW", "RW.", "W.", "RRW.WR", "RWW.."))
     for pile in piles:
         with self.subTest(pile):
             with self.assertRaises(UnableToMove):
                 attempt_to_move(pile, behaviours)
Exemplo n.º 5
0
 def test_long_move(self):
     """Long successful move"""
     piles = map(sp, ("R" * 100 + ".", "R" * 100 + ".W"))
     targets = map(sp, ("." + "R" * 100, "." + "R" * 100 + "W"))
     for pile, target in zip(piles, targets):
         with self.subTest(pile):
             self.assertEqual(attempt_to_move(pile, behaviours), target)
Exemplo n.º 6
0
 def test_simple_moves(self):
     """Simple successful moves"""
     piles = map(sp, ("R.", "R..", "R.R", "R.W", "RR.W", "R.R..W"))
     targets = map(sp, (".R", ".R.", ".RR", ".RW", ".RRW", ".RR..W"))
     for pile, target in zip(piles, targets):
         with self.subTest(pile):
             self.assertEqual(attempt_to_move(pile, behaviours), target)
Exemplo n.º 7
0
 def test_pushing(self):
     """Test pushing all the pieces of text"""
     behaviour = {"t": mb(push=True)}
     for text in chain(NOUNS, PROPERTIES, "i"):
         format_fun = lambda x: sp(x.format(text))
         piles = map(format_fun, ("{0}.", "{0}{0}.", "{0}.{0}"))
         targets = map(format_fun, (".{0}", ".{0}{0}", ".{0}{0}"))
         for pile, target in zip(piles, targets):
             with self.subTest(text=text):
                 self.assertEqual(attempt_to_move(pile, behaviour), target)
Exemplo n.º 8
0
 def test_no_behaviour(self):
     """Push entity with no associated behaviour dictionary"""
     for entity in ENTITIES:
         pile = sp("{}.".format(entity))
         with self.assertRaises(KeyError):
             attempt_to_move(pile, {})
Exemplo n.º 9
0
 def test_long_stuck(self):
     """Long pile raising UnableToMove exception"""
     piles = map(sp, ("R" * 100, "RW" + "." * 100, "W" * 100 + "."))
     for pile in piles:
         with self.assertRaises(UnableToMove):
             attempt_to_move(pile, behaviours)
Exemplo n.º 10
0
 def test_simple_null(self):
     """Simple null cases"""
     piles = map(sp, (".", ".R", ".RR", ".R.", ".R.R", ".W", ".WW", ".RW"))
     for pile in piles:
         with self.subTest(pile):
             self.assertEqual(attempt_to_move(pile, behaviours), pile)