def testCreateCubeSet(self):
        cubeSetName = 'test-' + str(uuid.uuid4())
        csvFileName =  cubeSetName + '.csv'
        shutil.copyfile('testdata.csv', cubeSetName + '.csv')
        with open('test_binnings.json') as binnings_file:
            binnings = json.load(binnings_file)
        with open('test_agg.json') as agg_file:
            aggs = json.load(agg_file)

        cs = CubeSetService('testdb')
        cs.createCubeSet("testOwner", cubeSetName, cubeSetName, csvFileName, binnings, aggs)

        cubeSet = cs.getCubeSet(cubeSetName)
        self.assertTrue(cubeSet != None)
        self.assertTrue(cubeSet['name'] == cubeSetName)
        self.assertTrue(cubeSet['displayName'] == cubeSetName)
        self.assertTrue(cubeSet['owner'] == 'testOwner')
        self.assertTrue(cubeSet['csvFileName'] == csvFileName)
        self.assertTrue(cubeSet['sourceCube'] == cubeSetName + '_source')
        self.assertTrue(cubeSet['binnedCube'] == cubeSetName + '_binned')
        binnedCubeName = cubeSet['binnedCube']
        self.assertTrue(len(cubeSet['aggCubes']) == 3)
        self.assertTrue(binnedCubeName + '_' + aggs[0]['name'] in cubeSet['aggCubes'])
        self.assertTrue(binnedCubeName + '_' + aggs[1]['name'] in cubeSet['aggCubes'])
        self.assertTrue(binnedCubeName + '_' + aggs[2]['name'] in cubeSet['aggCubes'])

        os.remove(csvFileName)
    def testDeleteCubeSet(self):
        cubeSetName = 'test-' + str(uuid.uuid4())
        csvFileName =  cubeSetName + '.csv'
        shutil.copyfile('testdata.csv', cubeSetName + '.csv')
        cs = CubeSetService('testdb')
        cs.createCubeSet("testOwner", cubeSetName, cubeSetName, csvFileName, None, None)
        cs.deleteCubeSet(cubeSetName)
        cubeSet = cs.getCubeSet(cubeSetName)
        self.assertTrue(cubeSet == None)

        os.remove(csvFileName)
    def testDeleteCubeSet2(self):
        cubeSetName = 'test-' + str(uuid.uuid4())
        csvFileName =  cubeSetName + '.csv'
        shutil.copyfile('testdata.csv', cubeSetName + '.csv')
        with open('test_binnings.json') as binnings_file:
            binnings = json.load(binnings_file)
        with open('test_agg.json') as agg_file:
            aggs = json.load(agg_file)

        cs = CubeSetService('testdb')
        cs.createCubeSet("testOwner", cubeSetName, cubeSetName, csvFileName, binnings, aggs)
        cs.deleteCubeSet(cubeSetName)
        cubeSet = cs.getCubeSet(cubeSetName)
        self.assertTrue(cubeSet == None)

        os.remove(csvFileName)
    def testUpdateCubeSetDisplayName(self):
        cubeSetName = 'test-' + str(uuid.uuid4())
        csvFileName =  cubeSetName + '.csv'
        shutil.copyfile('testdata.csv', cubeSetName + '.csv')
        cs = CubeSetService('testdb')
        cs.createCubeSet("testOwner", cubeSetName, cubeSetName, csvFileName, None, None)
        cs.updateCubeSetDisplayName(cubeSetName, 'new name')

        cubeSet = cs.getCubeSet(cubeSetName)
        self.assertTrue(cubeSet != None)
        self.assertTrue(cubeSet['name'] == cubeSetName)
        self.assertTrue(cubeSet['displayName'] == 'new name')
        self.assertTrue(cubeSet['owner'] == 'testOwner')
        self.assertTrue(cubeSet['csvFileName'] == csvFileName)
        self.assertTrue(cubeSet['sourceCube'] == cubeSetName + '_source')

        os.remove(csvFileName)