示例#1
0
    def it_provides_access_to_the_apparent_dimensions(self):
        dimension_dicts = CR.CA_X_MR_WEIGHTED_HS["result"]["dimensions"]
        all_dimensions = AllDimensions(dimension_dicts)

        apparent_dimension_types = tuple(
            d.dimension_type for d in all_dimensions.apparent_dimensions)

        assert apparent_dimension_types == (DT.CA, DT.CA_CAT, DT.MR)
示例#2
0
    def it_resolves_the_type_of_each_dimension(self, cube_response,
                                               expected_types):
        dimension_dicts = cube_response["result"]["dimensions"]
        all_dimensions = AllDimensions(dimension_dicts)

        dimension_types = tuple(d.dimension_type for d in all_dimensions)

        assert dimension_types == expected_types
示例#3
0
 def it_provides_the_means_missing_count_when_sum_are_available(self):
     cube_dict = CR.SUM_CAT_X_MR
     measures = _Measures(
         cube_dict,
         AllDimensions(dimension_dicts=cube_dict["result"]["dimensions"]),
     )
     missing_count = measures.missing_count
     assert missing_count == 1
示例#4
0
    def it_provides_access_to_wgtd_count_measure(self, cube_dict,
                                                 expected_type_name):
        measures = _Measures(
            cube_dict,
            AllDimensions(dimension_dicts=cube_dict["result"]["dimensions"]),
        )

        weighted_counts = measures.weighted_counts

        assert type(weighted_counts).__name__ == expected_type_name
示例#5
0
    def it_provides_access_to_the_mean_measure(self):
        cube_dict = CR.CAT_X_CAT_MEAN_WGTD
        measures = _Measures(
            cube_dict,
            AllDimensions(dimension_dicts=cube_dict["result"]["dimensions"]),
        )

        means = measures.means

        assert type(means).__name__ == "_MeanMeasure"
示例#6
0
    def it_provides_access_to_the_overlaps_measure(self):
        cube_dict = OL.CAT_X_MR_SUB_X_MR_SEL
        measures = _Measures(
            cube_dict,
            AllDimensions(dimension_dicts=cube_dict["result"]["dimensions"]),
        )

        overlaps = measures.overlaps

        assert type(overlaps).__name__ == "_OverlapMeasure"
示例#7
0
    def _all_dimensions(self):
        """The AllDimensions object for this cube.

        The AllDimensions object provides access to all the dimensions appearing in the
        cube response, not only apparent dimensions (those that appear to a user). It
        also provides access to an _ApparentDimensions object which contains only those
        user-apparent dimensions (basically the categories dimension of each MR
        dimension-pair is suppressed).
        """
        return AllDimensions(
            dimension_dicts=self._cube_dict["result"]["dimensions"])
示例#8
0
    def it_knows_if_its_dimensions_order(self, request, dim_types,
                                         expected_value):
        _dimensions_ = tuple(
            instance_mock(
                request, Dimension, name="dim-%d" % idx, dimension_type=dt)
            for idx, dt in enumerate(dim_types))
        _dimensions_prop_ = property_mock(request, AllDimensions,
                                          "_dimensions")
        _dimensions_prop_.return_value = _dimensions_

        assert AllDimensions(None).dimension_order == expected_value