def test_initialization(self): """No dimension on initialization should raise an exception.""" with self.assertRaises(ModelError): cubes.Hierarchy("default", [], self.dimension) with self.assertRaisesRegexp(ModelInconsistencyError, "not be empty"): cubes.Hierarchy("default", []) with self.assertRaisesRegexp(ModelInconsistencyError, "as strings"): cubes.Hierarchy("default", ["iamastring"])
def test_initialization(self): """No dimension on initialization should raise an exception.""" # self.assertRaises(ModelError, cubes.Hierarchy, "default", [self.levels[0]], None) self.assertRaises(ModelError, cubes.Hierarchy, "default", [], self.dimension) hier = cubes.Hierarchy("default", []) try: foo = hier.levels except ModelInconsistencyError: pass
def setUp(self): self.levels = [ cubes.Level("year", attributes=["year"]), cubes.Level("month", attributes=["month", "month_name", "month_sname"]), cubes.Level("day", attributes=["day"]), cubes.Level("week", attributes=["week"]) ] self.level_names = [level.name for level in self.levels] self.dimension = cubes.Dimension("date", levels=self.levels) self.hierarchy = cubes.Hierarchy("default", ["year", "month", "day"], self.dimension)