def test_last_tac(get_dataframe): """Test that last used TAC is right.""" tc = (get_dataframe(SubscriberTACs( "2016-01-01", "2016-01-02")).sort_values( by=["subscriber", "time"]).set_index("subscriber")) assert (tc.ix["zvaOknzKbEVD2eME"].tac.tolist()[-1] == get_dataframe( SubscriberTAC( "2016-01-01", "2016-01-02", method="last")).set_index("subscriber").ix["zvaOknzKbEVD2eME"].tac)
def test_modal_tac(get_dataframe): """ Test that most common tacs are right. """ tc = get_dataframe(SubscriberTACs("2016-01-01", "2016-01-02")).set_index("subscriber") assert (tc.loc["0DB8zw67E9mZAPK2"].tac.mode()[0] == get_dataframe( SubscriberTAC( "2016-01-01", "2016-01-02")).set_index("subscriber").loc["0DB8zw67E9mZAPK2"].tac)
def test_modal_tac(self): """ Test that most common tacs are right. """ tc = (SubscriberTACs( "2016-01-01", "2016-01-02").get_dataframe().set_index("subscriber")) self.assertEqual( tc.ix["0DB8zw67E9mZAPK2"].tac.mode()[0], SubscriberTAC("2016-01-01", "2016-01-02").get_dataframe().set_index( "subscriber").ix["0DB8zw67E9mZAPK2"].tac, )
def test_imei_warning(self): """Test that a warning is issued when imei is used as identifier.""" with self.assertWarns(UserWarning): SubscriberTAC("2016-01-01", "2016-01-02", subscriber_identifier="imei")
def test_tac_errors(): """ Test that correct ValueErrors are raised. """ with pytest.raises(ValueError, match="foo is not a valid method"): SubscriberTAC("2016-01-01", "2016-01-02", method="foo")