Ejemplo n.º 1
0
    def testShouldFailSinceIncorrectFace(self):
        cube = Cube()
        cubeCollection = collections.OrderedDict((('f', [
            'green', 'green', 'green', 'green', 'green', 'green', 'green',
            'green', 'green'
        ]), ('r', [
            'yellow', 'yellow', 'yellow', 'yellow', 'yellow', 'yellow',
            'yellow', 'yellow', 'yellow'
        ]), ('b', [
            'blue', 'blue', 'blue', 'blue', 'blue', 'blue', 'blue', 'blue',
            'blue'
        ]), ('l', [
            'white', 'white', 'white', 'white', 'white', 'white', 'white',
            'white', 'white'
        ]), ('t',
             ['red', 'red', 'red', 'red', 'red', 'red', 'red', 'red',
              'red']), ('u', [
                  'orange', 'orange', 'orange', 'orange', 'orange', 'orange',
                  'orange', 'orange', 'orange'
              ])))
        cube.sides = cubeCollection
        faceBeingRotated = 'blah'
        cube.rotateCube(faceBeingRotated)

        self.assertEquals('face is unknown', cube.error)
Ejemplo n.º 2
0
    def testShouldFailSinceIllegalCubeIncorrectSize(self):
        cube = Cube()
        cubeCollection = collections.OrderedDict((('f', [
            'red', 'blue', 'blue', 'green', 'orange', 'blue', 'red', 'green'
        ]), ('r', [
            'yellow', 'orange', 'white', 'green', 'red', 'yellow', 'yellow',
            'red', 'yellow'
        ]), ('b', [
            'red', 'white', 'orange', 'blue', 'blue', 'green', 'green',
            'white', 'red'
        ]), ('l', [
            'green', 'green', 'green', 'red', 'orange', 'orange', 'blue',
            'white', 'orange'
        ]), ('t', [
            'white', 'green', 'blue', 'yellow', 'white', 'white', 'white',
            'orange', 'orange'
        ]), ('u', [
            'white', 'yellow', 'orange', 'red', 'yellow', 'blue', 'yellow',
            'blue', 'red'
        ])))
        cube.sides = cubeCollection
        faceBeingRotated = 'f'

        cube.checkCube(cube.getCubeString())
        if cube.status != 'error':
            cube.rotateCube(faceBeingRotated)

        self.assertEquals('cube is not sized properly', cube.error)
Ejemplo n.º 3
0
 def testShouldTestRandomnessFidelity(self):
     cube = Cube()
     faces = collections.OrderedDict(
         (('f', ['g', 'g', 'g', 'g', 'g', 'g', 'g', 'g',
                 'g']), ('r', ['y', 'r', 'r', 'y', 'r', 'r', 'y', 'r',
                               'r']),
          ('b', ['b', 'b', 'b', 'b', 'b', 'b', 'b', 'b',
                 'b']), ('l', ['o', 'o', 'w', 'o', 'o', 'w', 'o', 'o',
                               'w']),
          ('t', ['w', 'w', 'w', 'w', 'w', 'w', 'r', 'r',
                 'r']), ('u', ['o', 'o', 'o', 'y', 'y', 'y', 'y', 'y',
                               'y'])))
     cube.sides = faces
     cube._randomness()
     self.assertEquals(cube.randomness, 67)
Ejemplo n.º 4
0
    def testShouldRotateFront(self):
        cube = Cube()
        faceBeingRotated = 'f'
        cubeCollection = collections.OrderedDict((('f', [
            'red', 'yellow', 'blue', 'blue', 'green', 'orange', 'blue', 'red',
            'green'
        ]), ('r', [
            'yellow', 'orange', 'white', 'green', 'yellow', 'yellow', 'yellow',
            'red', 'yellow'
        ]), ('b', [
            'red', 'white', 'orange', 'blue', 'blue', 'green', 'green',
            'white', 'red'
        ]), ('l', [
            'green', 'green', 'green', 'red', 'white', 'orange', 'blue',
            'white', 'orange'
        ]), ('t', [
            'white', 'green', 'blue', 'yellow', 'red', 'white', 'white',
            'orange', 'orange'
        ]), ('u', [
            'white', 'yellow', 'orange', 'red', 'orange', 'blue', 'yellow',
            'blue', 'red'
        ])))
        cube.sides = cubeCollection

        expectedRotatedCube = collections.OrderedDict((('f', [
            'blue', 'blue', 'red', 'red', 'green', 'yellow', 'green', 'orange',
            'blue'
        ]), ('r', [
            'white', 'orange', 'white', 'orange', 'yellow', 'yellow', 'orange',
            'red', 'yellow'
        ]), ('b', [
            'red', 'white', 'orange', 'blue', 'blue', 'green', 'green',
            'white', 'red'
        ]), ('l', [
            'green', 'green', 'white', 'red', 'white', 'yellow', 'blue',
            'white', 'orange'
        ]), ('t', [
            'white', 'green', 'blue', 'yellow', 'red', 'white', 'orange',
            'orange', 'green'
        ]), ('u', [
            'yellow', 'green', 'yellow', 'red', 'orange', 'blue', 'yellow',
            'blue', 'red'
        ])))

        cube.rotateCube(faceBeingRotated)

        self.assertEquals(expectedRotatedCube, cube.sides)