Пример #1
0
    def testGetAggregatedCubeRowsAll(self):
        cubeSetName = "test-" + str(uuid.uuid4())
        csvFilePath = cubeSetName + ".csv"
        try:
            shutil.copyfile("cubify/tests/testdata.csv", cubeSetName + ".csv")
        except Exception:
            shutil.copyfile("./testdata.csv", cubeSetName + ".csv")

        cs = CubeSetService("testdb")
        cubeSet = cs.createCubeSet("testOwner", cubeSetName, csvFilePath, None, None)
        cs.performAggregation(cubeSet, ["State", "ProductId"])

        aggCubeRows = cs.getAggregatedCubeRows(cubeSet, "ALL")

        dimkeys = []
        for aggCubeRow in aggCubeRows:
            dimkeys.append(aggCubeRow["dimensionKey"])
        dimkeys.sort()

        for dimkey in dimkeys:
            print dimkey

        self.assertEquals(dimkeys[0], "#State:CA")
        self.assertEquals(dimkeys[1], "#State:CA#ProductId:P1")
        self.assertEquals(dimkeys[2], "#State:CA#ProductId:P2")
        self.assertEquals(dimkeys[3], "#State:MA")
        self.assertEquals(dimkeys[4], "#State:MA#ProductId:P1")
        self.assertEquals(dimkeys[5], "#State:NY")
        self.assertEquals(dimkeys[6], "#State:NY#ProductId:P1")
        self.assertEquals(dimkeys[7], "#State:NY#ProductId:P2")

        os.remove(csvFilePath)
Пример #2
0
    def testPerformAggregation(self):

        cubeSetName = "test-" + str(uuid.uuid4())
        csvFilePath = cubeSetName + ".csv"
        try:
            shutil.copyfile("cubify/tests/testdata.csv", cubeSetName + ".csv")
        except Exception:
            shutil.copyfile("./testdata.csv", cubeSetName + ".csv")

        cs = CubeSetService("testdb")
        cubeSet = cs.createCubeSet("testOwner", cubeSetName, csvFilePath, None, None)
        aggCubes = cs.performAggregation(cubeSet, ["State", "ProductId"])
        self.assertTrue(len(aggCubes) == 2)

        aggCubeRows = cs.getAggregatedCubeRows(cubeSet, "State-ProductId")
        print aggCubeRows.count(False)
        self.assertTrue(aggCubeRows.count(False) == 5)
        for aggCubeRow in aggCubeRows:
            self.assertTrue(len(aggCubeRow["dimensions"]) == 2)
            print aggCubeRow

        print "---------"

        aggCubeRows = cs.getAggregatedCubeRows(cubeSet, "State")
        self.assertTrue(aggCubeRows.count(False) == 3)
        for aggCubeRow in aggCubeRows:
            self.assertTrue(len(aggCubeRow["dimensions"]) == 1)
            print aggCubeRow

        print "---------"

        os.remove(cubeSetName + ".csv")