Esempio n. 1
0
def test_aws_is_gzipped(case):
    # type: (TestCase) -> None
    clean_static_dir()
    create_static_file()
    case.assertIn("1 static file copied.", call_collectstatic())
    # file state should now be cached
    case.assertIn("0 static files copied.", call_collectstatic())
Esempio n. 2
0
def test_dry_run(case):
    # type: (TestCase) -> None
    clean_static_dir()
    create_static_file()
    result = call_collectstatic(dry_run=True)
    case.assertIn("1 static file copied.", result)
    case.assertTrue("Pretending to copy", result)
    result = call_collectstatic(dry_run=True)
    case.assertIn("1 static file copied.", result)
    case.assertTrue("Pretending to copy", result)
    case.assertTrue("Pretending to delete", result)
Esempio n. 3
0
def test_calls_post_copy_hook(_case: TestCase,
                              post_copy_hook: mock.MagicMock) -> None:
    clean_static_dir()
    path = create_static_file()
    cmd = Command()
    cmd.run_from_argv(["manage.py", "collectstatic", "--noinput"])
    post_copy_hook.assert_called_once_with(mock.ANY, path.name, path.name,
                                           mock.ANY)
Esempio n. 4
0
def test_calls_post_process_with_collected_files() -> None:
    clean_static_dir()
    path = create_static_file()

    cmd = Command()
    cmd.run_from_argv(["manage.py", "collectstatic", "--noinput"])
    cmd.storage.post_process.assert_called_once_with(
        {path.name: (mock.ANY, path.name)}, dry_run=False)
Esempio n. 5
0
    override_django_settings(
        STATICFILES_STORAGE="django.core.files.storage.FileSystemStorage",
        COLLECTFAST_STRATEGY=(
            "collectfast.strategies.filesystem.CachingFileSystemStrategy"),
    ),
}

make_test_aws_backends = test_many(**aws_backend_confs)
make_test_all_backends = test_many(**all_backend_confs)


@make_test_all_backends
@live_test
def test_basics(case: TestCase) -> None:
    clean_static_dir()
    create_static_file()
    case.assertIn("1 static file copied.", call_collectstatic())
    # file state should now be cached
    case.assertIn("0 static files copied.", call_collectstatic())


@make_test_all_backends
@live_test
@override_setting("threads", 5)
def test_threads(case: TestCase) -> None:
    clean_static_dir()
    create_static_file()
    case.assertIn("1 static file copied.", call_collectstatic())
    # file state should now be cached
    case.assertIn("0 static files copied.", call_collectstatic())
Esempio n. 6
0
def test_disable_collectfast(case):
    # type: (TestCase) -> None
    clean_static_dir()
    create_static_file()
    case.assertIn("1 static file copied.",
                  call_collectstatic(disable_collectfast=True))