test_custom_css_handler.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) Jupyter Development Team.
  2. # Distributed under the terms of the Modified BSD License.
  3. import os
  4. import pytest
  5. CUSTOM_CSS = """body #top-panel-wrapper,
  6. #jp-top-bar {
  7. background-color: #aecad4 !important;
  8. }
  9. body h1 {
  10. font-size: 22px;
  11. margin-bottom: 40px;
  12. color: #10929e;
  13. text-decoration: underline;
  14. }"""
  15. @pytest.fixture
  16. def jp_server_config(jp_server_config, tmp_path):
  17. config = jp_server_config.copy()
  18. config["LabApp"]["custom_css"] = True
  19. return config
  20. async def test_CustomCssHandler(tmp_path, jp_serverapp, labserverapp, jp_fetch):
  21. custom_path = tmp_path / "config" / "custom"
  22. # Check we are placing the custom.css file in the appropriate folder
  23. assert str(custom_path) in jp_serverapp.web_app.settings["static_custom_path"]
  24. custom_path.mkdir(parents=True, exist_ok=True)
  25. (custom_path / "custom.css").write_text(CUSTOM_CSS)
  26. response = await jp_fetch("custom", "custom.css", method="GET")
  27. assert response.code == 200
  28. assert response.body.decode().replace(os.linesep, "\n") == CUSTOM_CSS