mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-26 09:05:10 +00:00
test: use .localhost site names
This commit is contained in:
parent
eb2f56947b
commit
e8444e846e
3 changed files with 20 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ def check_cache():
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
frappe.connect(site="tests")
|
frappe.connect(site="tests.localhost")
|
||||||
check_db()
|
check_db()
|
||||||
check_cache()
|
check_cache()
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
@ -22,12 +23,27 @@ def _add_version_var(name: str, env_path: Path):
|
||||||
f.write(f"\n{name}={os.environ[name]}")
|
f.write(f"\n{name}={os.environ[name]}")
|
||||||
|
|
||||||
|
|
||||||
|
def _add_sites_var(env_path: Path):
|
||||||
|
with open(env_path, "r+") as f:
|
||||||
|
content = f.read()
|
||||||
|
content = re.sub(
|
||||||
|
rf"SITES=.*",
|
||||||
|
f"SITES=`tests.localhost`,`test-erpnext-site.localhost`,`test-pg-site.localhost`",
|
||||||
|
content,
|
||||||
|
)
|
||||||
|
f.seek(0)
|
||||||
|
f.truncate()
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def env_file(tmp_path_factory: pytest.TempPathFactory):
|
def env_file(tmp_path_factory: pytest.TempPathFactory):
|
||||||
tmp_path = tmp_path_factory.mktemp("frappe-docker")
|
tmp_path = tmp_path_factory.mktemp("frappe-docker")
|
||||||
file_path = tmp_path / ".env"
|
file_path = tmp_path / ".env"
|
||||||
shutil.copy("example.env", file_path)
|
shutil.copy("example.env", file_path)
|
||||||
|
|
||||||
|
_add_sites_var(file_path)
|
||||||
|
|
||||||
for var in ("FRAPPE_VERSION", "ERPNEXT_VERSION"):
|
for var in ("FRAPPE_VERSION", "ERPNEXT_VERSION"):
|
||||||
_add_version_var(name=var, env_path=file_path)
|
_add_version_var(name=var, env_path=file_path)
|
||||||
|
|
||||||
|
|
@ -52,7 +68,7 @@ def frappe_setup(compose: Compose):
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def frappe_site(compose: Compose):
|
def frappe_site(compose: Compose):
|
||||||
site_name = "tests"
|
site_name = "tests.localhost"
|
||||||
compose.bench(
|
compose.bench(
|
||||||
"new-site",
|
"new-site",
|
||||||
"--no-mariadb-socket",
|
"--no-mariadb-socket",
|
||||||
|
|
@ -77,7 +93,7 @@ def erpnext_setup(compose: Compose):
|
||||||
|
|
||||||
@pytest.fixture(scope="class")
|
@pytest.fixture(scope="class")
|
||||||
def erpnext_site(compose: Compose):
|
def erpnext_site(compose: Compose):
|
||||||
site_name = "test_erpnext_site"
|
site_name = "test-erpnext-site.localhost"
|
||||||
args = [
|
args = [
|
||||||
"new-site",
|
"new-site",
|
||||||
"--no-mariadb-socket",
|
"--no-mariadb-socket",
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ class TestPostgres:
|
||||||
def test_site_creation(self, compose: Compose):
|
def test_site_creation(self, compose: Compose):
|
||||||
compose.bench(
|
compose.bench(
|
||||||
"new-site",
|
"new-site",
|
||||||
"test_pg_site",
|
"test-pg-site.localhost",
|
||||||
"--db-type",
|
"--db-type",
|
||||||
"postgres",
|
"postgres",
|
||||||
"--admin-password",
|
"--admin-password",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue