fix: Use CI oriented FakeWebpackLoader
This was added in a newer version of django-webpack loader to be used in CI. Previously we had some monkey patches to deal with this but they could break when changes happen to the upstream django-webpack-loader library. This should be a more robust solution to keep CI working and to reduce complexity on future upgrades.
This commit is contained in:
@@ -40,23 +40,3 @@ def _django_clear_site_cache():
|
|||||||
with what has been working for us so far.
|
with what has been working for us so far.
|
||||||
"""
|
"""
|
||||||
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
pass # lint-amnesty, pylint: disable=unnecessary-pass
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def no_webpack_loader(monkeypatch):
|
|
||||||
"""
|
|
||||||
Monkeypatch webpack_loader to make sure that webpack assets don't need to be
|
|
||||||
compiled before unit tests are run.
|
|
||||||
"""
|
|
||||||
monkeypatch.setattr(
|
|
||||||
"webpack_loader.templatetags.webpack_loader.render_bundle",
|
|
||||||
lambda context, entry, extension=None, config='DEFAULT', attrs='': ''
|
|
||||||
)
|
|
||||||
monkeypatch.setattr(
|
|
||||||
"webpack_loader.utils.get_as_tags",
|
|
||||||
lambda entry, extension=None, config='DEFAULT', attrs='': []
|
|
||||||
)
|
|
||||||
monkeypatch.setattr(
|
|
||||||
"webpack_loader.utils.get_files",
|
|
||||||
lambda entry, extension=None, config='DEFAULT', attrs='': []
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ TEST_ROOT = path("test_root")
|
|||||||
# Want static files in the same dir for running on jenkins.
|
# Want static files in the same dir for running on jenkins.
|
||||||
STATIC_ROOT = TEST_ROOT / "staticfiles"
|
STATIC_ROOT = TEST_ROOT / "staticfiles"
|
||||||
WEBPACK_LOADER["DEFAULT"]["STATS_FILE"] = STATIC_ROOT / "webpack-stats.json"
|
WEBPACK_LOADER["DEFAULT"]["STATS_FILE"] = STATIC_ROOT / "webpack-stats.json"
|
||||||
|
WEBPACK_LOADER['DEFAULT']['LOADER_CLASS'] = 'webpack_loader.loader.FakeWebpackLoader'
|
||||||
|
|
||||||
GITHUB_REPO_ROOT = TEST_ROOT / "data"
|
GITHUB_REPO_ROOT = TEST_ROOT / "data"
|
||||||
DATA_DIR = TEST_ROOT / "data"
|
DATA_DIR = TEST_ROOT / "data"
|
||||||
|
|||||||
16
conftest.py
16
conftest.py
@@ -15,19 +15,3 @@ from cms.conftest import _django_clear_site_cache, pytest_configure # pylint: d
|
|||||||
# When using self.assertEquals, diffs are truncated. We don't want that, always
|
# When using self.assertEquals, diffs are truncated. We don't want that, always
|
||||||
# show the whole diff.
|
# show the whole diff.
|
||||||
TestCase.maxDiff = None
|
TestCase.maxDiff = None
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def no_webpack_loader(monkeypatch): # lint-amnesty, pylint: disable=missing-function-docstring
|
|
||||||
monkeypatch.setattr(
|
|
||||||
"webpack_loader.templatetags.webpack_loader.render_bundle",
|
|
||||||
lambda context, entry, extension=None, config='DEFAULT', attrs='': ''
|
|
||||||
)
|
|
||||||
monkeypatch.setattr(
|
|
||||||
"webpack_loader.utils.get_as_tags",
|
|
||||||
lambda entry, extension=None, config='DEFAULT', attrs='': []
|
|
||||||
)
|
|
||||||
monkeypatch.setattr(
|
|
||||||
"webpack_loader.utils.get_files",
|
|
||||||
lambda entry, extension=None, config='DEFAULT', attrs='': []
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ TEST_ROOT = path("test_root")
|
|||||||
# Want static files in the same dir for running on jenkins.
|
# Want static files in the same dir for running on jenkins.
|
||||||
STATIC_ROOT = TEST_ROOT / "staticfiles"
|
STATIC_ROOT = TEST_ROOT / "staticfiles"
|
||||||
WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json"
|
WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json"
|
||||||
|
WEBPACK_LOADER['DEFAULT']['LOADER_CLASS'] = 'webpack_loader.loader.FakeWebpackLoader'
|
||||||
|
|
||||||
STATUS_MESSAGE_PATH = TEST_ROOT / "status_message.json"
|
STATUS_MESSAGE_PATH = TEST_ROOT / "status_message.json"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user