Exemplo n.º 1
0
 def setUp(self):
     super(TestFileSystemFinder, self).setUp()
     self.finder = finders.FileSystemFinder()
     test_file_path = os.path.join(TEST_ROOT, 'project', 'documents',
                                   'test', 'file.txt')
     self.find_first = (os.path.join('test', 'file.txt'), test_file_path)
     self.find_all = (os.path.join('test', 'file.txt'), [test_file_path])
Exemplo n.º 2
0
 def test_non_tuple_raises_exception(self):
     """
     We can't determine if STATICFILES_DIRS is set correctly just by
     looking at the type, but we can determine if it's definitely wrong.
     """
     with self.assertRaises(ImproperlyConfigured):
         finders.FileSystemFinder()
Exemplo n.º 3
0
 def setUp(self):
     super().setUp()
     self.finder = finders.FileSystemFinder()
     test_file_path = os.path.join(
         TEST_ROOT, "project", "documents", "test", "file.txt"
     )
     self.find_first = (os.path.join("test", "file.txt"), test_file_path)
     self.find_all = (os.path.join("test", "file.txt"), [test_file_path])
Exemplo n.º 4
0
 def test_default_case(self):
     response = self.panel.process_request(self.request)
     self.panel.generate_stats(self.request, response)
     content = self.panel.content
     self.assertIn(
         "django.contrib.staticfiles.finders.AppDirectoriesFinder", content)
     self.assertIn(
         "django.contrib.staticfiles.finders.FileSystemFinder (2 files)",
         content)
     self.assertEqual(self.panel.num_used, 0)
     self.assertNotEqual(self.panel.num_found, 0)
     self.assertEqual(self.panel.get_staticfiles_apps(),
                      ["django.contrib.admin", "debug_toolbar"])
     self.assertEqual(self.panel.get_staticfiles_dirs(),
                      finders.FileSystemFinder().locations)
Exemplo n.º 5
0
 def test_default_case(self):
     self.panel.process_request(self.request)
     self.panel.process_response(self.request, self.response)
     self.assertIn(
         'django.contrib.staticfiles.finders.'
         'AppDirectoriesFinder', self.panel.content)
     self.assertIn(
         'django.contrib.staticfiles.finders.'
         'FileSystemFinder (2 files)', self.panel.content)
     self.assertEqual(self.panel.num_used, 0)
     self.assertNotEqual(self.panel.num_found, 0)
     self.assertEqual(self.panel.get_staticfiles_apps(),
                      ['django.contrib.admin', 'debug_toolbar'])
     self.assertEqual(self.panel.get_staticfiles_dirs(),
                      finders.FileSystemFinder().locations)
Exemplo n.º 6
0
    def test_finder_directory_does_not_exist(self):
        """Misconfigure the static files settings and verify the toolbar runs.

        The test case is that the STATIC_ROOT is in STATICFILES_DIRS and that
        the directory of STATIC_ROOT does not exist.
        """
        response = self.panel.process_request(self.request)
        self.panel.generate_stats(self.request, response)
        content = self.panel.content
        self.assertIn(
            "django.contrib.staticfiles.finders.AppDirectoriesFinder", content)
        self.assertNotIn(
            "django.contrib.staticfiles.finders.FileSystemFinder (2 files)",
            content)
        self.assertEqual(self.panel.num_used, 0)
        self.assertNotEqual(self.panel.num_found, 0)
        self.assertEqual(self.panel.get_staticfiles_apps(),
                         ["django.contrib.admin", "debug_toolbar"])
        self.assertEqual(self.panel.get_staticfiles_dirs(),
                         finders.FileSystemFinder().locations)
Exemplo n.º 7
0
def file_path_finder(path):
    """
    Return physical path of file if found.
    """
    return finders.FileSystemFinder().find(path)
Exemplo n.º 8
0
 def setUp(self):
     super(TestFileSystemFinder, self).setUp()
     self.finder = finders.FileSystemFinder()
     test_file_path = os.path.join(TEST_ROOT, 'project/documents/test/file.txt')
     self.find_first = ("test/file.txt", test_file_path)
     self.find_all = ("test/file.txt", [test_file_path])