Skip to content

Commit

Permalink
ENH - Make conda-store-server test port configurable (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcpevey authored Sep 15, 2023
1 parent 469afda commit 274c759
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
10 changes: 8 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from requests import Session
from urllib.parse import urljoin


CONDA_STORE_SERVER_PORT = os.environ.get(
"CONDA_STORE_SERVER_PORT", f"5000"
)
CONDA_STORE_BASE_URL = os.environ.get(
"CONDA_STORE_BASE_URL", "http://localhost:5000/conda-store/"
"CONDA_STORE_BASE_URL", f"http://localhost:{CONDA_STORE_SERVER_PORT}/conda-store/"
)
CONDA_STORE_USERNAME = os.environ.get("CONDA_STORE_USERNAME", "username")
CONDA_STORE_PASSWORD = os.environ.get("CONDA_STORE_PASSWORD", "password")
Expand Down Expand Up @@ -45,3 +47,7 @@ def login(
def testclient():
session = CondaStoreSession(CONDA_STORE_BASE_URL)
yield session

@pytest.fixture
def server_port():
return CONDA_STORE_SERVER_PORT
18 changes: 9 additions & 9 deletions tests/test_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


@pytest.mark.playwright
def test_integration(page: Page):
# Go to http://localhost:5000/conda-store/admin/
page.goto("http://localhost:5000/conda-store/admin/", wait_until="domcontentloaded")
def test_integration(page: Page, server_port):
# Go to http://localhost:{server_port}/conda-store/admin/
page.goto(f"http://localhost:{server_port}/conda-store/admin/", wait_until="domcontentloaded")
page.screenshot(path="test-results/conda-store-unauthenticated.png")

# Click text=Login
page.locator("text=Login").click()
# expect(page).to_have_url("http://localhost:5000/conda-store/login/")
# expect(page).to_have_url(f"http://localhost:{server_port}/conda-store/login/")

# Click [placeholder="Username"]
page.locator('[placeholder="Username"]').click()
Expand All @@ -27,7 +27,7 @@ def test_integration(page: Page):
page.locator('[placeholder="Password"]').fill("password")

# Click button:has-text("Sign In")
# with page.expect_navigation(url="http://localhost:5000/conda-store/"):
# with page.expect_navigation(url=f"http://localhost:{server_port}/conda-store/"):
with page.expect_navigation():
page.locator('button:has-text("Sign In")').click()

Expand All @@ -41,11 +41,11 @@ def test_integration(page: Page):

# Press Enter
page.locator('[placeholder="Search"]').press("Enter")
# expect(page).to_have_url("http://localhost:5000/conda-store/?search=python")
# expect(page).to_have_url(f"http://localhost:{server_port}/conda-store/?search=python")

# Click text=filesystem/python-flask-env
page.locator("text=filesystem / python-flask-env").click()
# expect(page).to_have_url("http://localhost:5000/conda-store/environment/filesystem/python-flask-env/")
# expect(page).to_have_url(f"http://localhost:{server_port}/conda-store/environment/filesystem/python-flask-env/")

page.locator("a", has_text="Build").click()

Expand All @@ -61,7 +61,7 @@ def test_integration(page: Page):

page.screenshot(path="test-results/conda-store-build-complete.png")

page.goto("http://localhost:5000/conda-store/admin/")
page.goto(f"http://localhost:{server_port}/conda-store/admin/")

page.goto("http://localhost:5000/conda-store/")
page.goto(f"http://localhost:{server_port}/conda-store/")
time.sleep(5)

0 comments on commit 274c759

Please sign in to comment.