def test_unmoving_column_names(get_column_names_from_run): assert (get_column_names_from_run( Unmoving(locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=3), )))) == ["subscriber", "value"])
def test_unmoving_counts_column_names(get_column_names_from_run): assert get_column_names_from_run( RedactedUnmovingCounts(unmoving_counts=UnmovingCounts( Unmoving(locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=3), )))))) == ["pcod", "value"]
def test_unmoving_values(get_dataframe): df = get_dataframe( Unmoving(locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=3), )))).set_index("subscriber") assert not df.loc["038OVABN11Ak4W5P"].value assert df.loc["0Gl95NRLjW2aw8pW"].value
def test_unmoving_counts_values(get_dataframe): df = get_dataframe( UnmovingCounts( Unmoving(locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=3), ))))).set_index("pcod") assert df.loc["524 1 02 09"].value == 5 assert df.loc["524 2 04 20"].value == 7
def test_unmoving_counts_values(get_dataframe): df = get_dataframe( RedactedUnmovingCounts(unmoving_counts=UnmovingCounts( Unmoving(locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=2), )))))).set_index("pcod") with pytest.raises(KeyError): assert df.loc["524 1 02"].value assert df.loc["524 4 12"].value == 29
def test_unmoving_at_reference_location_column_names( get_column_names_from_run): assert get_column_names_from_run( UnmovingAtReferenceLocation( locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=3), )), reference_locations=LastLocation("2016-01-01", "2016-01-02"), )) == ["subscriber", "value"]
def test_unmoving_at_reference_location_values(get_dataframe): df = get_dataframe( UnmovingAtReferenceLocation( locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=3), )), reference_locations=LastLocation("2016-01-01", "2016-01-02"), )).set_index("subscriber") assert not df.loc["038OVABN11Ak4W5P"].value assert df.loc["3XKdxqvyNxO2vLD1"].value
def test_spatial_unit_mismatch_error(): with pytest.raises(ValueError, match="Spatial unit mismatch"): UnmovingAtReferenceLocation( locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=2), )), reference_locations=LastLocation( "2016-01-01", "2016-01-02", spatial_unit=make_spatial_unit("admin", level=3), ), )
def test_unmoving_at_reference_location_counts_values(get_dataframe): df = get_dataframe( UnmovingAtReferenceLocationCounts( UnmovingAtReferenceLocation( locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=1), )), reference_locations=LastLocation( "2016-01-01", "2016-01-02", spatial_unit=make_spatial_unit("admin", level=1), ), ))).set_index("pcod") assert df.loc["524 1"].value == 2 assert df.loc["524 4"].value == 26
def test_unmoving_at_reference_location_counts_column_names( get_column_names_from_run): assert (get_column_names_from_run( RedactedUnmovingAtReferenceLocationCounts( unmoving_at_reference_location_counts= UnmovingAtReferenceLocationCounts( UnmovingAtReferenceLocation( locations=UniqueLocations( SubscriberLocations( "2016-01-01", "2016-01-01 10:00", spatial_unit=make_spatial_unit("admin", level=1), )), reference_locations=LastLocation( "2016-01-01", "2016-01-02", spatial_unit=make_spatial_unit("admin", level=1), ), )))) == ["pcod", "value"])