Ejemplo 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())
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    "cachingfilesystem":
    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())
Ejemplo n.º 6
0
def test_no_load_with_disable_flag(
        mocked_load_strategy: mock.MagicMock) -> None:
    clean_static_dir()
    call_collectstatic(disable_collectfast=True)
    mocked_load_strategy.assert_not_called()
Ejemplo n.º 7
0
def test_no_load_with_disable_setting(
        mocked_load_strategy: mock.MagicMock) -> None:
    clean_static_dir()
    call_collectstatic()
    mocked_load_strategy.assert_not_called()
Ejemplo n.º 8
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))