예제 #1
0
    def test_basic(self):
        md = {}
        with self.assertRaises(ModelError):
            measure = create_measure(md)

        measure = create_measure("amount")
        self.assertIsInstance(measure, Measure)
        self.assertEqual("amount", measure.name)

        md = {"name": "amount"}
        measure = create_measure(md)
        self.assertEqual("amount", measure.name)
예제 #2
0
파일: test_model.py 프로젝트: 6si/cubes
    def test_basic(self):
        md = {}
        with self.assertRaises(ModelError):
            measure = create_measure(md)

        measure = create_measure("amount")
        self.assertIsInstance(measure, Measure)
        self.assertEqual("amount", measure.name)

        md = {"name": "amount"}
        measure = create_measure(md)
        self.assertEqual("amount", measure.name)
예제 #3
0
    def test_create_default_aggregates(self):
        measure = create_measure("amount")
        aggs = measure.default_aggregates()
        self.assertEqual(1, len(aggs))
        agg = aggs[0]
        self.assertEqual("amount_sum", agg.name)
        self.assertEqual("amount", agg.measure)
        self.assertEqual("sum", agg.function)
        self.assertIsNone(agg.formula)

        md = {"name": "amount", "aggregates": ["sum", "min"]}
        measure = create_measure(md)
        aggs = measure.default_aggregates()
        self.assertEqual(2, len(aggs))
        self.assertEqual("amount_sum", aggs[0].name)
        self.assertEqual("amount", aggs[0].measure)
        self.assertEqual("sum", aggs[0].function)
        self.assertIsNone(aggs[0].formula)

        self.assertEqual("amount_min", aggs[1].name)
        self.assertEqual("amount", aggs[1].measure)
        self.assertEqual("min", aggs[1].function)
        self.assertIsNone(aggs[1].formula)
예제 #4
0
파일: test_model.py 프로젝트: 6si/cubes
    def test_create_default_aggregates(self):
        measure = create_measure("amount")
        aggs = measure.default_aggregates()
        self.assertEqual(1, len(aggs))
        agg = aggs[0]
        self.assertEqual("amount_sum", agg.name)
        self.assertEqual("amount", agg.measure)
        self.assertEqual("sum", agg.function)
        self.assertIsNone(agg.formula)

        md = {"name": "amount", "aggregates": ["sum", "min"]}
        measure = create_measure(md)
        aggs = measure.default_aggregates()
        self.assertEqual(2, len(aggs))
        self.assertEqual("amount_sum", aggs[0].name)
        self.assertEqual("amount", aggs[0].measure)
        self.assertEqual("sum", aggs[0].function)
        self.assertIsNone(aggs[0].formula)

        self.assertEqual("amount_min", aggs[1].name)
        self.assertEqual("amount", aggs[1].measure)
        self.assertEqual("min", aggs[1].function)
        self.assertIsNone(aggs[1].formula)
예제 #5
0
 def test_copy(self):
     md = {"name": "amount"}
     measure = create_measure(md)
     measure2 = copy.deepcopy(measure)
     self.assertEqual(measure, measure2)
예제 #6
0
파일: test_model.py 프로젝트: 6si/cubes
 def test_copy(self):
     md = {"name": "amount"}
     measure = create_measure(md)
     measure2 = copy.deepcopy(measure)
     self.assertEqual(measure, measure2)