'Test the availability of variables (serialized as JSON) in templates'

def test_template_with_json_variable(self):

    val = {'success': False, 'test_value': {'foo': 'bar', 'obj': {'v1': 'yes', 'v2': 'no'}}}
    Variable.set('a_variable', val['test_value'], serialize_json=True)
    def verify_templated_field(context):
        self.assertEqual(context['ti'].task.some_templated_field, val['test_value']['obj']['v2'])
        val['success'] = True
    t = OperatorSubclass(task_id='test_complex_template', some_templated_field='{{    var.json.a_variable.obj.v2    }}', on_success_callback=verify_templated_field, dag=self.dag)
    t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)
    self.assertTrue(val['success'])
