def test_get_template(self):
     with mock.patch.object(NotificationTemplate, '_parsed_templates', {}):
         self.assertNotIn(
             'blah blah blah', NotificationTemplate._parsed_templates)
         t = NotificationTemplate._get_template('blah blah blah')
         self.assertIn(
             'blah blah blah', NotificationTemplate._parsed_templates)
         self.assertEqual(
             t, NotificationTemplate._get_template('blah blah blah'))
Ejemplo n.º 2
0
 def test_get_template(self):
     with mock.patch.object(NotificationTemplate, '_parsed_templates', {}):
         self.assertNotIn('blah blah blah',
                          NotificationTemplate._parsed_templates)
         t = NotificationTemplate._get_template('blah blah blah')
         self.assertIn('blah blah blah',
                       NotificationTemplate._parsed_templates)
         self.assertEqual(
             t, NotificationTemplate._get_template('blah blah blah'))
 def test_choose_appropriate_renderer(self):
     with mock.patch.object(mbs.mbs, 'DEFAULT_TEMPLATE_DIR_ROOT',
                            self._temp_dir):
         with mock.patch.object(
                 mbs.notification.template.MustacheNotificationTemplate,
                 'render_string') as mnt, \
              mock.patch.object(
                  NotificationTemplate, 'render_string') as nt:
             NotificationTemplate.render_path('foo/bar/bar.string', {})
             NotificationTemplate.render_path('foo/baz/baz.mustache', {})
             self.assertEqual(mnt.call_count, 1)
             self.assertEqual(nt.call_count, 1)
Ejemplo n.º 4
0
 def test_choose_appropriate_renderer(self):
     with mock.patch.object(mbs.mbs, 'DEFAULT_TEMPLATE_DIR_ROOT',
                            self._temp_dir):
         with mock.patch.object(
                 mbs.notification.template.MustacheNotificationTemplate,
                 'render_string') as mnt, \
              mock.patch.object(
                  NotificationTemplate, 'render_string') as nt:
             NotificationTemplate.render_path('foo/bar/bar.string', {})
             NotificationTemplate.render_path('foo/baz/baz.mustache', {})
             self.assertEqual(mnt.call_count, 1)
             self.assertEqual(nt.call_count, 1)
 def test_render_path(self):
     with mock.patch.object(mbs.mbs, 'DEFAULT_TEMPLATE_DIR_ROOT',
                            self._temp_dir):
         self.assertEqual(
             NotificationTemplate.render_path(
                 'foo/bar/bar.string', {'name': 'test'}),
             '\nHi, my name is test.\n')
Ejemplo n.º 6
0
 def test_renderer_case_insensitivity(self):
     with mock.patch.object(mbs.mbs, 'DEFAULT_TEMPLATE_DIR_ROOT',
                            self._temp_dir):
         open(os.path.join(self._temp_dir, 'case.STRING'),
              'w').write('blah')
         self.assertEqual(
             NotificationTemplate.render_path('case.STRING', {}), 'blah')
Ejemplo n.º 7
0
 def test_render_path(self):
     with mock.patch.object(mbs.mbs, 'DEFAULT_TEMPLATE_DIR_ROOT',
                            self._temp_dir):
         self.assertEqual(
             NotificationTemplate.render_path('foo/bar/bar.string',
                                              {'name': 'test'}),
             '\nHi, my name is test.\n')
 def test_renderer_case_insensitivity(self):
     with mock.patch.object(mbs.mbs, 'DEFAULT_TEMPLATE_DIR_ROOT',
                            self._temp_dir):
         open(os.path.join(
             self._temp_dir, 'case.STRING'), 'w').write('blah')
         self.assertEqual(
             NotificationTemplate.render_path(
                 'case.STRING', {}), 'blah')