def test_test_content_templating(self): test = Test() handler = ContentHandler() handler.is_template_content = True handler.content = '{"first_name": "Gaius","id": "$id","last_name": "Baltar","login": "******"}' context = Context() context.bind_variables({'id': 9, 'login': '******'}) test.set_body(handler) templated = test.realize(context=context) self.assertEqual(string.Template(handler.content).safe_substitute(context.get_values()), templated.body)
def test_test_content_templating(self): test = Test() handler = ContentHandler() handler.is_template_content = True handler.content = '{"first_name": "Gaius","id": "$id","last_name": "Baltar","login": "******"}' context = Context() context.bind_variables({'id':9, 'login':'******'}) test.set_body(handler) templated = test.realize(context=context) self.assertEqual(string.Template(handler.content).safe_substitute(context.get_values()), templated.body)
def test_variables(self): """ Test bind/return of variables """ context = Context() self.assertTrue(context.get_value('foo') is None) self.assertEqual(0, context.mod_count) context.bind_variable('foo','bar') self.assertEqual('bar', context.get_value('foo')) self.assertEqual('bar', context.get_values()['foo']) self.assertEqual(1, context.mod_count) context.bind_variable('foo','bar2') self.assertEqual('bar2', context.get_value('foo')) self.assertEqual(2, context.mod_count)
def test_variables(self): """ Test bind/return of variables """ context = Context() self.assertTrue(context.get_value('foo') is None) self.assertEqual(0, context.mod_count) context.bind_variable('foo', 'bar') self.assertEqual('bar', context.get_value('foo')) self.assertEqual('bar', context.get_values()['foo']) self.assertEqual(1, context.mod_count) context.bind_variable('foo', 'bar2') self.assertEqual('bar2', context.get_value('foo')) self.assertEqual(2, context.mod_count)