示例#1
0
def test_redacted_unique_visitor_counts(get_dataframe):
    """
    Values test for redacted unique visitor counts.
    """
    activity = RedactedUniqueVisitorCounts(
        unique_visitor_counts=UniqueVisitorCounts(
            ActiveAtReferenceLocationCounts(
                ActiveAtReferenceLocation(
                    subscriber_locations=UniqueLocations(
                        SubscriberLocations(
                            "2016-01-01",
                            "2016-01-02",
                            spatial_unit=make_spatial_unit("admin", level=3),
                        )),
                    reference_locations=daily_location("2016-01-03"),
                )),
            UniqueSubscriberCounts(
                "2016-01-01",
                "2016-01-02",
                spatial_unit=make_spatial_unit("admin", level=3),
            ),
        ))
    df = get_dataframe(activity).set_index("pcod")
    assert len(df) == 2
    assert df.loc["524 3 08 44"].value == 170
示例#2
0
    def _flowmachine_query_obj(self):
        """
        Return the underlying flowmachine object.

        Returns
        -------
        Query
        """
        # Note we're not using the redacted version here, because the two composing queries are redacted
        return UniqueVisitorCounts(
            active_at_reference_location_counts=self.active_at_reference_location_counts._flowmachine_query_obj,
            unique_subscriber_counts=self.unique_subscriber_counts._flowmachine_query_obj,
        )
def test_unique_visitor_counts_column_names(get_column_names_from_run):
    assert (get_column_names_from_run(
        UniqueVisitorCounts(
            ActiveAtReferenceLocationCounts(
                ActiveAtReferenceLocation(
                    subscriber_locations=UniqueLocations(
                        SubscriberLocations(
                            "2016-01-01",
                            "2016-01-02",
                            spatial_unit=make_spatial_unit("admin", level=3),
                        )),
                    reference_locations=daily_location("2016-01-03"),
                )),
            UniqueSubscriberCounts(
                "2016-01-01",
                "2016-01-02",
                spatial_unit=make_spatial_unit("admin", level=3),
            ),
        )) == ["pcod", "value"])