def test_unpack_trackable_urls(self): p = STEParser() self.assertRaises(STEIOError, p.unpack_trackable_urls) p.load(self.template) self.assertRaises(STEImproperlyConfigured, p.unpack_trackable_urls) p.ctd_url = "http://example.com" p.template = """ <html> <head> <title>[Response: Read Receipt]</title> </head> <body>[Response: Read Receipt] [Field: ACC_NO] <a target="_blank" href="[*Trackable URL: IPhone_offer]" style="color: #464646;">IPhone</a> <a target="_blank" href="[*Trackable URL: SGS_offer]" style="color: #464646;">SGS</a> </body></html> """ names = p.unpack_trackable_urls() self.assertNotIn("Trackable URL", p.template) self.assertIn("IPhone_offer_T", p.template) self.assertIn("SGS_offer_T", p.template) self.assertIn(p.ctd_url, p.template) self.assertEqual(names, set(['IPhone_offer', 'SGS_offer']))
def test_condition(self): p = STEParser() p.load(self.template) p.template = "<!-- $(if [Field: ATTR_RAIF] == 1 and [Field: ATTR_RAIF] != 2) -->1<!-- $(endif) -->" + \ "<!-- $(if [Field: ATTR_RAIF] == 1 or [Field: ATTR_RAIF] != 2) -->2<!-- $(endif) -->" p.variables = {'ATTR_RAIF': '1'} self.assertEqual("12", p.render())