def test_belasting_tip_no_optin(self): client_data = get_fixture(optin=False) response = self.client.post("/tips/gettips", json=client_data) belasting_tip = None for i in response.get_json(): if i["id"] == "belasting-5": belasting_tip = i self.assertIsNone(belasting_tip)
def test_belasting_tip(self): client_data = get_fixture(optin=True) response = self.client.post("/tips/gettips", json=client_data) belasting_tip = None for i in response.get_json(): if i["id"] == "belasting-5": belasting_tip = i self.assertEqual( belasting_tip["reason"], ["U krijgt deze tip omdat u nog niet via automatische incasso betaalt"], ) self.assertEqual( belasting_tip["imgUrl"], "api/tips/static/tip_images/belastingen.jpg" )
def test_allow_listed_fields(self): tip1_mock = get_tip() tip2_mock = get_tip() tip1_mock["isPersonalized"] = True tip2_mock["isPersonalized"] = True tips_pool = [tip1_mock, tip2_mock] tips = tips_generator(get_tips_request_data(get_fixture(optin=True)), tips_pool) # only these fields are allowed extended_fields_list = sorted(FRONT_END_TIP_KEYS) fields = sorted(tips[0].keys()) self.assertEqual(extended_fields_list, fields) fields = sorted(tips[1].keys()) self.assertEqual(extended_fields_list, fields)
def _get_tips_request_data(self): return get_tips_request_data(get_fixture())