Beispiel #1
0
    def test_links(self):
        dims = dict((d.name, d) for d in self.dimensions)

        links = [{"name": "date"}]
        cube = Cube("contracts", dimension_links=links, measures=self.measures)
        cube.link_dimensions(dims)
        self.assertEqual(len(cube.dimensions), 1)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 2)

        links = [{"name": "date"}, "product", "flag"]
        cube = Cube("contracts", dimension_links=links, measures=self.measures)
        cube.link_dimensions(dims)
        self.assertEqual(len(cube.dimensions), 3)
        self.assertIsInstance(cube.dimension("flag"), Dimension)
Beispiel #2
0
    def test_links(self):
        dims = dict((d.name, d) for d in self.dimensions)

        links = [{"name": "date"}]
        cube = Cube("contracts",
                          dimension_links=links,
                          measures=self.measures)
        cube.link_dimensions(dims)
        self.assertEqual(len(cube.dimensions), 1)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 2)

        links = [{"name": "date"}, "product", "flag"]
        cube = Cube("contracts",
                          dimension_links=links,
                          measures=self.measures)
        cube.link_dimensions(dims)
        self.assertEqual(len(cube.dimensions), 3)
        self.assertIsInstance(cube.dimension("flag"), Dimension)
Beispiel #3
0
    def test_link_hierarchies(self):
        dims = dict((d.name, d) for d in self.dimensions)

        links = [{"name": "date"}]
        cube = Cube("contracts",
                          dimension_links=links,
                          measures=self.measures)
        cube.link_dimensions(dims)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 2)
        self.assertEqual(dim.hierarchy().name, "ymd")

        links = [{"name": "date", "nonadditive":None}]
        cube = Cube("contracts",
                          dimension_links=links,
                          measures=self.measures)
        cube.link_dimensions(dims)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 2)
        self.assertEqual(dim.hierarchy().name, "ymd")

        links = [{"name": "date", "hierarchies": ["ym"]}]
        cube = Cube("contracts",
                          dimension_links=links,
                          measures=self.measures)
        cube.link_dimensions(dims)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 1)
        self.assertEqual(dim.hierarchy().name, "ym")
Beispiel #4
0
    def test_link_hierarchies(self):
        dims = dict((d.name, d) for d in self.dimensions)

        links = [{"name": "date"}]
        cube = Cube("contracts", dimension_links=links, measures=self.measures)
        cube.link_dimensions(dims)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 2)
        self.assertEqual(dim.hierarchy().name, "ymd")

        links = [{"name": "date", "nonadditive": None}]
        cube = Cube("contracts", dimension_links=links, measures=self.measures)
        cube.link_dimensions(dims)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 2)
        self.assertEqual(dim.hierarchy().name, "ymd")

        links = [{"name": "date", "hierarchies": ["ym"]}]
        cube = Cube("contracts", dimension_links=links, measures=self.measures)
        cube.link_dimensions(dims)
        dim = cube.dimension("date")
        self.assertEqual(len(dim.hierarchies), 1)
        self.assertEqual(dim.hierarchy().name, "ym")