def test_to_dict(self): desc = self.cube.to_dict() dims = dict((dim.name, dim) for dim in self.dimensions) cube = Cube.from_metadata(desc, dims) self.assertEqual(self.cube.dimensions, cube.dimensions) self.assertEqual(self.cube.measures, cube.measures) self.assertEqual(self.cube, cube)
def test_create_cube(self): cube = { "name": "cube", "dimensions": ["date"], "aggregates": ["record_count"], "details": ["some_detail", "another_detail"] } cube = Cube.from_metadata(cube) self.assertEqual(cube.name, "cube") self.assertEqual(len(cube.aggregates), 1) self.assertEqual(len(cube.details), 2)
def test_inherit_nonadditive(self): dims = [DIM_DATE_DESC, DIM_PRODUCT_DESC, DIM_FLAG_DESC] cube = { "name": "contracts", "dimensions": ["date", "product"], "nonadditive": "time", "measures": ["amount", "discount"] } dims = [Dimension.from_metadata(md) for md in dims] dims = dict((dim.name, dim) for dim in dims) cube = Cube.from_metadata(cube) measures = cube.measures self.assertEqual(measures[0].nonadditive, "time")
def cube(self, name): """Create a cube object `name` from measures test model.""" return Cube.from_metadata(self.cubes_md[name])