예제 #1
0
  def testRenderKMLTemplateWithFilledCache(self):
    self.mox.StubOutWithMock(template, 'Context')
    mock_template = self.mox.CreateMockAnything()
    dummy_file = object()
    dummy_args = object()
    dummy_context = object()
    dummy_result = object()
    self.stubs.Set(model, '_kml_template_cache', {dummy_file: mock_template})

    template.Context(dummy_args).AndReturn(dummy_context)
    mock_template.render(dummy_context).AndReturn(dummy_result)
    self.mox.ReplayAll()
    self.assertEqual(model._RenderKMLTemplate(dummy_file, dummy_args),
                     dummy_result)
예제 #2
0
  def testRenderKMLTemplateWithEmptyCache(self):
    self.mox.StubOutWithMock(template, 'register_template_library')
    self.mox.StubOutWithMock(template, 'load')
    self.mox.StubOutWithMock(template, 'Context')
    mock_template = self.mox.CreateMockAnything()
    mock_cache = {}
    dummy_file = 'dummy'
    dummy_args = object()
    dummy_context = object()
    dummy_result = object()
    self.stubs.Set(model, '_kml_template_cache', mock_cache)

    template.register_template_library('template_functions.kml')
    template.load('kml_templates/dummy').AndReturn(mock_template)
    template.Context(dummy_args).AndReturn(dummy_context)
    mock_template.render(dummy_context).AndReturn(dummy_result)
    self.mox.ReplayAll()
    self.assertEqual(model._RenderKMLTemplate(dummy_file, dummy_args),
                     dummy_result)
    self.assertEqual(mock_cache[dummy_file], mock_template)