コード例 #1
0
 def test_theme_url__nofile(self):
     self.create_theme(default=True)
     path = 'path/to/file.pth'
     with mock.patch('uploadtemplate.templatetags.uploadtemplate.default_storage') as storage:
         storage.exists.return_value = False
         static(Context(), path)
         self.assertFalse(storage.url.called)
コード例 #2
0
 def test_staticfiles_url(self):
     self.create_theme(default=False)
     path = 'path/to/file.pth'
     context = Context()
     with mock.patch('django.contrib.staticfiles.storage.staticfiles_storage') as storage:
         static(context, path)
         storage.url.assert_called_once_with(path)
コード例 #3
0
 def test_theme_url__nofile(self):
     self.create_theme(default=True)
     path = 'path/to/file.pth'
     with mock.patch(
             'uploadtemplate.templatetags.uploadtemplate.default_storage'
     ) as storage:
         storage.exists.return_value = False
         static(Context(), path)
         self.assertFalse(storage.url.called)
コード例 #4
0
 def test_staticfiles_url(self):
     self.create_theme(default=False)
     path = 'path/to/file.pth'
     context = Context()
     with mock.patch(
             'django.contrib.staticfiles.storage.staticfiles_storage'
     ) as storage:
         static(context, path)
         storage.url.assert_called_once_with(path)
コード例 #5
0
 def test_theme_url(self):
     theme = self.create_theme(default=True)
     path = 'path/to/file.pth'
     name = os.path.join(theme.theme_files_dir, 'static', path)
     if not default_storage.exists(name):
         default_storage.save(name, ContentFile(''))
     with mock.patch('uploadtemplate.templatetags.uploadtemplate.default_storage') as storage:
         static(Context(), path)
         storage.url.assert_called_once_with(name)
コード例 #6
0
 def test_theme_url(self):
     theme = self.create_theme(default=True)
     path = 'path/to/file.pth'
     name = os.path.join(theme.theme_files_dir, 'static', path)
     if not default_storage.exists(name):
         default_storage.save(name, ContentFile(''))
     with mock.patch(
             'uploadtemplate.templatetags.uploadtemplate.default_storage'
     ) as storage:
         static(Context(), path)
         storage.url.assert_called_once_with(name)
コード例 #7
0
 def test_static_url(self):
     self.create_theme(default=False)
     path = 'path/to/file.pth'
     with mock.patch('django.contrib.staticfiles.storage.staticfiles_storage') as storage:
         url = static(Context(), path)
         self.assertFalse(storage.url.called)
     self.assertEqual(url, urlparse.urljoin(settings.STATIC_URL, path))
コード例 #8
0
 def test_static_url(self):
     self.create_theme(default=False)
     path = 'path/to/file.pth'
     with mock.patch(
             'django.contrib.staticfiles.storage.staticfiles_storage'
     ) as storage:
         url = static(Context(), path)
         self.assertFalse(storage.url.called)
     self.assertEqual(url, urlparse.urljoin(settings.STATIC_URL, path))
コード例 #9
0
 def render(self, context):
     path = self.path.resolve(context)
     return static(context, path)
コード例 #10
0
 def render(self, context):
     path = self.path.resolve(context)
     return static(context, path)