예제 #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 test_active_at_reference_location_counts_column_names(
        get_column_names_from_run):
    assert get_column_names_from_run(
        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"),
            ))) == ["pcod", "value"]
예제 #3
0
    def _flowmachine_query_obj(self):
        """
        Return the underlying flowmachine unique locations object.

        Returns
        -------
        Query
        """
        return RedactedActiveAtReferenceLocationCounts(
            active_at_reference_location_counts=ActiveAtReferenceLocationCounts(
                active_at_reference_location=ActiveAtReferenceLocation(
                    reference_locations=self.reference_locations.
                    _flowmachine_query_obj,
                    subscriber_locations=self.unique_locations.
                    _flowmachine_query_obj,
                ), ))
예제 #4
0
def test_active_at_reference_location_counts(get_dataframe):
    """
    Values test for active at reference location counts.
    """
    activity = 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"),
        ))
    df = get_dataframe(activity).set_index("pcod")
    assert df.loc["524 1 01 04"][0] == 1
def test_redacted_active_at_reference_location_counts(get_dataframe):
    """
    Values test for redacted active at reference location counts.
    """
    activity = RedactedActiveAtReferenceLocationCounts(
        active_at_reference_location_counts=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"),
            )))
    df = get_dataframe(activity).set_index("pcod")
    assert all(df.value > 15)
    assert len(df) == 2
    assert df.loc["524 3 08 44"].value == 25