コード例 #1
0
    def test_can_unlock_door_no_lock(self):
        keyring = maze.Keyring()
        door = maze.Door(maze.Room(), maze.Room())

        can_unlock = keyring.can_unlock(door)

        self.assertTrue(can_unlock)
コード例 #2
0
    def test_add_duplicate_key(self):
        keyring = maze.Keyring()

        keyring.add_key("blue")
        keyring.add_key("blue")

        self.assertEqual(keyring.keys, ["blue"])
コード例 #3
0
    def test_cannot_unlock_door_missing_key(self):
        keyring = maze.Keyring()
        lock = maze.Lock()
        keyring.add_key("blue")
        lock.add_fitting_key("red")
        door = maze.Door(maze.Room(), maze.Room(), lock)

        can_unlock = keyring.can_unlock(door)

        self.assertFalse(can_unlock)
コード例 #4
0
    def test_can_unlock_door_having_key(self):
        key = "blue"
        keyring = maze.Keyring()
        lock = maze.Lock()
        keyring.add_key(key)
        lock.add_fitting_key(key)
        door = maze.Door(maze.Room(), maze.Room(), lock)

        can_unlock = keyring.can_unlock(door)

        self.assertTrue(can_unlock)