Пример #1
0
    def test_has_details(self):
        """Level "has_details" flag"""
        attrs = cubes.attribute_list(["year"])
        level = cubes.Level("year", attrs)
        self.assertFalse(level.has_details)

        attrs = cubes.attribute_list(["month", "month_name"])
        level = cubes.Level("month", attrs)
        self.assertTrue(level.has_details)
Пример #2
0
 def setUp(self):
     a = [DIM_DATE_DESC, DIM_PRODUCT_DESC, DIM_FLAG_DESC]
     self.measures = cubes.attribute_list(["amount", "discount"], Measure)
     self.details = cubes.attribute_list(["detail"], Attribute)
     self.dimensions = [cubes.create_dimension(desc) for desc in a]
     self.cube = cubes.Cube("contracts",
                             dimensions=self.dimensions,
                             measures=self.measures,
                             details=self.details)
Пример #3
0
    def test_has_details(self):
        """Level "has_details" flag"""
        attrs = cubes.attribute_list(["year"])
        level = cubes.Level("year", attrs)
        self.assertFalse(level.has_details)

        attrs = cubes.attribute_list(["month", "month_name"])
        level = cubes.Level("month", attrs)
        self.assertTrue(level.has_details)
Пример #4
0
 def setUp(self):
     a = [DIM_DATE_DESC, DIM_PRODUCT_DESC, DIM_FLAG_DESC]
     self.measures = attribute_list(["amount", "discount"], Measure)
     self.details = attribute_list(["detail"], Attribute)
     self.dimensions = [create_dimension(desc) for desc in a]
     self.cube = Cube("contracts",
                      dimensions=self.dimensions,
                      measures=self.measures,
                      details=self.details)
Пример #5
0
    def test_attribute_list(self):
        """Create attribute list from strings or Attribute instances"""
        self.assertEqual([], cubes.attribute_list([]))

        names = ["name", "key"]
        attrs = cubes.attribute_list(names)

        for name, attr in zip(names, attrs):
            self.assertIsInstance(attr, cubes.Attribute)
            self.assertEqual(name, attr.name)
Пример #6
0
    def test_attribute_list(self):
        """Create attribute list from strings or Attribute instances"""
        self.assertEqual([], cubes.attribute_list([]))

        names = ["name", "key"]
        attrs = cubes.attribute_list(names)

        for name, attr in zip(names, attrs):
            self.assertIsInstance(attr, cubes.Attribute)
            self.assertEqual(name, attr.name)
Пример #7
0
    def test_comparison(self):
        """Comparison of level instances"""

        attrs = cubes.attribute_list(["info", "code", "name"])
        level1 = cubes.Level("product", attrs, key="code", label_attribute="name")
        level2 = cubes.Level("product", attrs, key="code", label_attribute="name")
        level3 = cubes.Level("product", attrs)
        attrs = cubes.attribute_list(["month", "month_name"])
        level4 = cubes.Level("product", attrs)

        self.assertEqual(level1, level2)
        self.assertNotEqual(level2, level3)
        self.assertNotEqual(level2, level4)
Пример #8
0
    def test_comparison(self):
        """Comparison of level instances"""

        attrs = attribute_list(["info", "code", "name"])
        level1 = Level("product", attrs, key="code", label_attribute="name")
        level2 = Level("product", attrs, key="code", label_attribute="name")
        level3 = Level("product", attrs)
        attrs = attribute_list(["month", "month_name"])
        level4 = Level("product", attrs)

        self.assertEqual(level1, level2)
        self.assertNotEqual(level2, level3)
        self.assertNotEqual(level2, level4)
Пример #9
0
 def setUp(self):
     a = [DIM_DATE_DESC, DIM_PRODUCT_DESC, DIM_FLAG_DESC]
     self.measures = cubes.attribute_list(["amount", "discount"])
     self.dimensions = [cubes.create_dimension(desc) for desc in a]
     self.cube = cubes.Cube("contracts",
                            dimensions=self.dimensions,
                            measures=self.measures)
Пример #10
0
 def setUp(self):
     a = [DIM_DATE_DESC, DIM_PRODUCT_DESC, DIM_FLAG_DESC]
     self.measures = cubes.attribute_list(["amount", "discount"])
     self.dimensions = [cubes.create_dimension(desc) for desc in a]
     self.cube = cubes.Cube("contracts",
                            dimensions=self.dimensions,
                            measures=self.measures)
     self.model = cubes.Model(cubes=[self.cube], dimensions=self.dimensions)
     self.model_path = os.path.join(DATA_PATH, 'model.json')
Пример #11
0
 def setUp(self):
     a = [DIM_DATE_DESC, DIM_PRODUCT_DESC, DIM_FLAG_DESC]
     self.measures = cubes.attribute_list(["amount", "discount"])
     self.dimensions = [cubes.create_dimension(desc) for desc in a]
     self.cube = cubes.Cube("contracts",
                             dimensions=self.dimensions,
                             measures=self.measures)
     self.model = cubes.Model(cubes=[self.cube],
                              dimensions=self.dimensions)
     self.model_path = os.path.join(DATA_PATH, 'model.json')
Пример #12
0
    def test_key_label_attributes(self):
        """Test key and label attributes - explicit and implicit"""

        attrs = cubes.attribute_list(["code"])
        level = cubes.Level("product", attrs)
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("code", str(level.label_attribute))

        attrs = cubes.attribute_list(["code", "name"])
        level = cubes.Level("product", attrs)
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("name", str(level.label_attribute))

        attrs = cubes.attribute_list(["info", "code", "name"])
        level = cubes.Level("product",
                            attrs,
                            key="code",
                            label_attribute="name")
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("name", str(level.label_attribute))

        # Test key/label in full desc
        desc = {
            "name": "product",
            "attributes": ["info", "code", "name"],
            "label_attribute": "name",
            "key": "code"
        }

        level = cubes.create_level(desc)
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("name", str(level.label_attribute))
Пример #13
0
    def setUp(self):
        super(ModelTestCase, self).setUp()

        a = [DIM_DATE_DESC, DIM_PRODUCT_DESC, DIM_FLAG_DESC]
        self.measures = cubes.attribute_list(["amount", "discount"], Measure)
        self.dimensions = [cubes.create_dimension(desc) for desc in a]
        self.cube = cubes.Cube("contracts",
                                dimensions=self.dimensions,
                                measures=self.measures)
        self.model = cubes.Model(cubes=[self.cube],
                                 dimensions=self.dimensions)

        self.model_file = "model.json"
Пример #14
0
    def test_key_label_attributes(self):
        """Test key and label attributes - explicit and implicit"""

        attrs = cubes.attribute_list(["code"])
        level = cubes.Level("product", attrs)
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("code", str(level.label_attribute))

        attrs = cubes.attribute_list(["code", "name"])
        level = cubes.Level("product", attrs)
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("name", str(level.label_attribute))

        attrs = cubes.attribute_list(["info", "code", "name"])
        level = cubes.Level("product", attrs, key="code",
                            label_attribute="name")
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("name", str(level.label_attribute))

        # Test key/label in full desc
        desc = {
            "name": "product",
            "attributes": ["info", "code", "name"],
            "label_attribute": "name",
            "key": "code"
        }

        level = cubes.create_level(desc)
        self.assertIsInstance(level.key, cubes.Attribute)
        self.assertEqual("code", str(level.key))
        self.assertIsInstance(level.label_attribute, cubes.Attribute)
        self.assertEqual("name", str(level.label_attribute))