Example #1
0
def server():
    try:
        parm = {}
        for key in request.args:
            parm[key] = str(request.args[key])
        result = RCube.dispatch(parm)
        return str(result)
    except Exception as e:
        return e
Example #2
0
    def test100_980_TestToSeeThatThereAreSameAmountOfColorsOnCube(self):

        inputParm = {'op': 'scramble', 'size': 2}
        result = RCube.dispatch(inputParm)
        finalResult = result['cube']

        appearancesOf1 = finalResult.count(1)
        appearancesOf6 = finalResult.count(6)

        self.assertEquals(appearancesOf1, appearancesOf6)
Example #3
0
 def test101_001_ShouldReturnErrorDueToNoFace(self):
     inputParm = {
         'op':
         'rotate',
         'cube': [
             1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
             3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
             5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6
         ]
     }
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #4
0
 def test101_023_ShouldReturnStatusOfErrorOnCheckOnCubeOfIncorrectSize(
         self):  #done
     inputParm = {
         'op':
         'check',
         'cube': [
             2, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6,
             6, 6
         ]
     }
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #5
0
 def test101_016_ShouldReturnStatusOfFullOnCheckOnEvenSizeCube(self):  #done
     inputParm = {
         'op':
         'check',
         'cube': [
             1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6,
             6, 6, 6
         ]
     }
     result = RCube.dispatch(inputParm)
     finalResult = result['status']
     self.assertEquals('full', finalResult)
Example #6
0
 def test101_019_ShouldReturnStatusOfCrossesOnCheckOnOddSizeCubeSize3(
         self):  #done
     inputParm = {
         'op':
         'check',
         'cube': [
             2, 1, 2, 1, 1, 1, 2, 1, 2, 3, 2, 3, 2, 2, 2, 3, 2, 3, 4, 3, 4,
             3, 3, 3, 4, 3, 4, 5, 4, 5, 4, 4, 4, 5, 4, 5, 6, 5, 6, 5, 5, 5,
             6, 5, 6, 1, 6, 1, 6, 6, 6, 1, 6, 1
         ]
     }
     result = RCube.dispatch(inputParm)
     finalResult = result['status']
     self.assertEquals('crosses', finalResult)
Example #7
0
 def test101_021_ShouldReturnStatusOfUnknownOnCheckOnOddSizeCube(
         self):  #done
     inputParm = {
         'op':
         'check',
         'cube': [
             2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
             3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
             5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6
         ]
     }
     result = RCube.dispatch(inputParm)
     finalResult = result['status']
     self.assertEquals('unknown', finalResult)
Example #8
0
 def test101_003_ShouldReturnRotatedAsStatus(self):
     inputParm = {
         'op':
         'rotate',
         'cube': [
             1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
             3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
             5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6
         ],
         'face':
         "F"
     }
     result = RCube.dispatch(inputParm)
     finalResult = result['status']
     self.assertEquals('rotated', finalResult)
Example #9
0
 def test101_010_ShouldReturnRotatedCubeFaceD(self):
     inputParm = {
         'op':
         'rotate',
         'cube': [
             1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
             3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
             5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6
         ],
         'face':
         "D"
     }
     result = RCube.dispatch(inputParm)
     finalResult = result['cube']
     cube = [
         1, 1, 1, 1, 1, 1, 4, 4, 4, 2, 2, 2, 2, 2, 2, 1, 1, 1, 3, 3, 3, 3,
         3, 3, 2, 2, 2, 4, 4, 4, 4, 4, 4, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5,
         5, 6, 6, 6, 6, 6, 6, 6, 6, 6
     ]
     self.assertEquals(cube, finalResult)
Example #10
0
 def test101_013_ShouldReturnRotatedCubeFaceBbackwards(self):
     inputParm = {
         'op':
         'rotate',
         'cube': [
             1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 6, 2, 2, 6, 2, 2, 6, 3, 3, 3,
             3, 3, 3, 3, 3, 3, 5, 4, 4, 5, 4, 4, 5, 4, 4, 2, 2, 2, 5, 5, 5,
             5, 5, 5, 6, 6, 6, 6, 6, 6, 4, 4, 4
         ],
         'face':
         "B'"
     }
     result = RCube.dispatch(inputParm)
     finalResult = result['cube']
     cube = [
         1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
         3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
         5, 6, 6, 6, 6, 6, 6, 6, 6, 6
     ]
     self.assertEquals(cube, finalResult)
Example #11
0
 def test100_990_TestToCheckThatThereIsACenterSquareForEveryColor(self):
     inputParm = {'size': 1, 'op': 'scramble'}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #12
0
 def test100_981_ShouldReturnStatusScrambled(self):
     inputParm = {'op': 'scramble', 'size': 2}
     result = RCube.dispatch(inputParm)
     finalResult = result['status']
     self.assertEquals('scrambled', finalResult)
Example #13
0
 def test100_010_ShouldIndicateErrorConditionalMissingOp(self):
     inputParm = {}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #14
0
 def test100_970_ShouldReturnScrambledCubeBackwardsParm(self):
     inputParm = {'size': 2, 'op': 'scramble'}
     result = RCube.dispatch(inputParm)
     finalResult = result['cube']
     self.assertEquals(len(finalResult), 2 * 2 * 6)
Example #15
0
 def test100_960_ShouldReturnErrorOfSizeTooSmall(self):
     inputParm = {'op': 'scramble', 'size': 1}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #16
0
 def test101_024_ShouldReturnStatusOfErrorOnCheckOnMissingCube(self):  #done
     inputParm = {'op': 'check'}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #17
0
 def test100_020_ShouldIndicateErrorOpIsMissing(self):
     inputParm = {'op'}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #18
0
 def test100_ShouldReturnError(self):
     #queryString = "op=check&f=f&r=r&b=b&l=l&t=t&u=u&cube=f,f,f,t,f,f,f,f,f,r,r,r,r,r,r,r,r,r,b,u,b,b,b,b,b,b,b,l,l,l,l,l,l,l,l,l,t,t,t,f,t,t,t,t,t,u,u,u,b,u,u,u,u,u"
     parm = {'op':'check','f':'f', 'r':'r', 'b':'b','l':'l', 't':'t', 'u':'u', 'cube':'f,f,f,f,f,f,t,f,f,r,r,r,r,r,r,r,r,r,f,b,b,b,b,b,b,b,b,l,l,l,l,l,l,l,l,l,t,t,t,t,t,t,t,t,b,u,u,u,u,u,u,u,u,u'}   
     RCube.dispatch(parm) 
Example #19
0
 def test100_020_ShouldIndicateErrorOpIsSetToSomethingNotScramble(self):
     inputParm = {'op' == 'init'}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #20
0
 def test101_014_ShouldReturnScrambledCubeChecksForCenterFOrAllColorsOnOddSizeCube(
         self):  #not done yet
     inputParm = {'op': 'scramble'}
     result = RCube.dispatch(inputParm)
     finalResult = result['cube']
     self.assertEquals(len(finalResult), 3 * 3 * 6)
Example #21
0
 def test100_991_TestToCheckThatThereAreFourCornerForEachColor(self):
     inputParm = {'size': 1, 'op': 'scramble'}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])
Example #22
0
 def test100_940_ShouldReturnScrambledCubeOfSize30(self):
     inputParm = {'op': 'scramble', 'size': 30}
     result = RCube.dispatch(inputParm)
     finalResult = result['cube']
     self.assertEquals(len(finalResult), 30 * 30 * 6)
Example #23
0
 def test100_920_ShouldReturnScrambledCubeOfSizeThreeMissingSize(self):
     inputParm = {'op': 'scramble'}
     result = RCube.dispatch(inputParm)
     finalResult = result['cube']
     self.assertEquals(len(finalResult), 3 * 3 * 6)
Example #24
0
 def test900_ShouldReturnError(self):
     #queryString = "op=check&f=f&r=r&b=b&l=l&t=t&u=u&cube=f,f,f,t,f,f,f,f,f,r,r,r,r,r,r,r,r,r,b,u,b,b,b,b,b,b,b,l,l,l,l,l,l,l,l,l,t,t,t,f,t,t,t,t,t,u,u,u,b,u,u,u,u,u"
     parm = {'op':'scramble', 'n':'6', 'method':'transition'}   
     RCube.dispatch(parm)     
Example #25
0
 def test101_000_ShouldReturnErrorDueToNoCube(self):
     inputParm = {'op': 'rotate', 'face': "F"}
     result = RCube.dispatch(inputParm)
     self.assertEquals('error:', result['status'][0:6])