Exemplo n.º 1
0
 def test_assign(self):
     p = STEParser()
     vars = {
         'CRH_FIRST_NAME_ORIG': 'Bivis',
         'ACC_BALANCE_PTS': 123,
         'First Name': 'Ushat Pomoev',
     }
     for k, v in vars.items():
         p.assign(k, v)
         self.assertEqual(p.variables[k], str(v))
         self.assertIsInstance(p.variables[k], str)
Exemplo n.º 2
0
 def test_render(self):
     p = STEParser(self.template)
     p.variables = {
                 'CRH_FIRST_NAME_ORIG': 'Bivis',
                 'ACC_BALANCE_PTS': '123',
                 'First Name': 'Ushat Pomoev',
                 'ATTR_RAIF': '0',
                 'ATTR_VS': '1',
                 'ATTR_VSSS': '0',
     }
     p.render()
Exemplo n.º 3
0
    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']))
Exemplo n.º 4
0
 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())
Exemplo n.º 5
0
 def test_load(self):
     p = STEParser()
     p.load(self.template)