|
@@ -4,6 +4,7 @@ from pathlib import Path
|
|
|
|
|
|
import pytest
|
|
import pytest
|
|
|
|
|
|
|
|
+from reflex import constants
|
|
from reflex.compiler import compiler, utils
|
|
from reflex.compiler import compiler, utils
|
|
from reflex.utils.imports import ImportVar, ParsedImportDict
|
|
from reflex.utils.imports import ImportVar, ParsedImportDict
|
|
|
|
|
|
@@ -124,6 +125,13 @@ def test_compile_stylesheets(tmp_path: Path, mocker):
|
|
"button.rt-Button {\n\tborder-radius:unset !important;\n}"
|
|
"button.rt-Button {\n\tborder-radius:unset !important;\n}"
|
|
)
|
|
)
|
|
mocker.patch("reflex.compiler.compiler.Path.cwd", return_value=project)
|
|
mocker.patch("reflex.compiler.compiler.Path.cwd", return_value=project)
|
|
|
|
+ mocker.patch(
|
|
|
|
+ "reflex.compiler.compiler.get_web_dir",
|
|
|
|
+ return_value=project / constants.Dirs.WEB,
|
|
|
|
+ )
|
|
|
|
+ mocker.patch(
|
|
|
|
+ "reflex.compiler.utils.get_web_dir", return_value=project / constants.Dirs.WEB
|
|
|
|
+ )
|
|
|
|
|
|
stylesheets = [
|
|
stylesheets = [
|
|
"https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple",
|
|
"https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple",
|
|
@@ -133,7 +141,7 @@ def test_compile_stylesheets(tmp_path: Path, mocker):
|
|
]
|
|
]
|
|
|
|
|
|
assert compiler.compile_root_stylesheet(stylesheets) == (
|
|
assert compiler.compile_root_stylesheet(stylesheets) == (
|
|
- str(Path(".web") / "styles" / "styles.css"),
|
|
|
|
|
|
+ str(project / constants.Dirs.WEB / "styles" / "styles.css"),
|
|
"@import url('./tailwind.css'); \n"
|
|
"@import url('./tailwind.css'); \n"
|
|
"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
|
|
"@import url('https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple'); \n"
|
|
"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n"
|
|
"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css'); \n"
|
|
@@ -141,7 +149,7 @@ def test_compile_stylesheets(tmp_path: Path, mocker):
|
|
"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n",
|
|
"@import url('https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css'); \n",
|
|
)
|
|
)
|
|
|
|
|
|
- assert (project / ".web" / "styles" / "styles.css").read_text() == (
|
|
|
|
|
|
+ assert (project / constants.Dirs.WEB / "styles" / "styles.css").read_text() == (
|
|
assets_dir / "styles.css"
|
|
assets_dir / "styles.css"
|
|
).read_text()
|
|
).read_text()
|
|
|
|
|
|
@@ -173,6 +181,13 @@ def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
|
|
"button.rt-Button {\n\tborder-radius:unset !important;\n}"
|
|
"button.rt-Button {\n\tborder-radius:unset !important;\n}"
|
|
)
|
|
)
|
|
mocker.patch("reflex.compiler.compiler.Path.cwd", return_value=project)
|
|
mocker.patch("reflex.compiler.compiler.Path.cwd", return_value=project)
|
|
|
|
+ mocker.patch(
|
|
|
|
+ "reflex.compiler.compiler.get_web_dir",
|
|
|
|
+ return_value=project / constants.Dirs.WEB,
|
|
|
|
+ )
|
|
|
|
+ mocker.patch(
|
|
|
|
+ "reflex.compiler.utils.get_web_dir", return_value=project / constants.Dirs.WEB
|
|
|
|
+ )
|
|
|
|
|
|
stylesheets = [
|
|
stylesheets = [
|
|
"/styles.css",
|
|
"/styles.css",
|
|
@@ -181,7 +196,7 @@ def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
|
|
]
|
|
]
|
|
|
|
|
|
assert compiler.compile_root_stylesheet(stylesheets) == (
|
|
assert compiler.compile_root_stylesheet(stylesheets) == (
|
|
- str(Path(".web") / "styles" / "styles.css"),
|
|
|
|
|
|
+ str(project / constants.Dirs.WEB / "styles" / "styles.css"),
|
|
"@import url('./tailwind.css'); \n"
|
|
"@import url('./tailwind.css'); \n"
|
|
"@import url('./styles.css'); \n"
|
|
"@import url('./styles.css'); \n"
|
|
f"@import url('./{Path('preprocess') / Path('styles_a.css')!s}'); \n"
|
|
f"@import url('./{Path('preprocess') / Path('styles_a.css')!s}'); \n"
|
|
@@ -194,23 +209,23 @@ def test_compile_stylesheets_scss_sass(tmp_path: Path, mocker):
|
|
]
|
|
]
|
|
|
|
|
|
assert compiler.compile_root_stylesheet(stylesheets) == (
|
|
assert compiler.compile_root_stylesheet(stylesheets) == (
|
|
- str(Path(".web") / "styles" / "styles.css"),
|
|
|
|
|
|
+ str(project / constants.Dirs.WEB / "styles" / "styles.css"),
|
|
"@import url('./tailwind.css'); \n"
|
|
"@import url('./tailwind.css'); \n"
|
|
"@import url('./styles.css'); \n"
|
|
"@import url('./styles.css'); \n"
|
|
f"@import url('./{Path('preprocess') / Path('styles_b.css')!s}'); \n"
|
|
f"@import url('./{Path('preprocess') / Path('styles_b.css')!s}'); \n"
|
|
f"@import url('./{Path('preprocess') / Path('styles_a.css')!s}'); \n",
|
|
f"@import url('./{Path('preprocess') / Path('styles_a.css')!s}'); \n",
|
|
)
|
|
)
|
|
|
|
|
|
- assert (project / ".web" / "styles" / "styles.css").read_text() == (
|
|
|
|
|
|
+ assert (project / constants.Dirs.WEB / "styles" / "styles.css").read_text() == (
|
|
assets_dir / "styles.css"
|
|
assets_dir / "styles.css"
|
|
).read_text()
|
|
).read_text()
|
|
|
|
|
|
expected_result = "button.rt-Button{border-radius:unset !important}\n"
|
|
expected_result = "button.rt-Button{border-radius:unset !important}\n"
|
|
assert (
|
|
assert (
|
|
- project / ".web" / "styles" / "preprocess" / "styles_a.css"
|
|
|
|
|
|
+ project / constants.Dirs.WEB / "styles" / "preprocess" / "styles_a.css"
|
|
).read_text() == expected_result
|
|
).read_text() == expected_result
|
|
assert (
|
|
assert (
|
|
- project / ".web" / "styles" / "preprocess" / "styles_b.css"
|
|
|
|
|
|
+ project / constants.Dirs.WEB / "styles" / "preprocess" / "styles_b.css"
|
|
).read_text() == expected_result
|
|
).read_text() == expected_result
|
|
|
|
|
|
|
|
|