Premier test UI

This commit is contained in:
Colin Maudry
2026-02-04 23:33:59 +01:00
parent 39af4bafbe
commit 61dbf237cf
5 changed files with 94 additions and 1 deletions
+17
View File
@@ -22,5 +22,22 @@ dependencies = [
[project.optional-dependencies]
dev = [
"pytest",
"pytest-env",
"pre-commit",
"selenium",
"webdriver-manager",
"dash[testing]",
]
[tool.pytest.ini_options]
pythonpath = [
"src"
]
testpaths = [
"tests"
]
env = [
"DATA_FILE_PARQUET_PATH=tests/test.parquet"
]
addopts = "-p no:warnings"
+5 -1
View File
@@ -9,6 +9,10 @@ from flask import Response
load_dotenv()
# if os.getenv("PYTEST_CURRENT_TEST"):
# os.environ["DATA_FILE_PARQUET_PATH"]
development = os.getenv("DEVELOPMENT").lower() == "true"
meta_tags = [
@@ -22,7 +26,7 @@ meta_tags = [
if development:
meta_tags.append({"name": "robots", "content": "noindex"})
app = Dash(
app: Dash = Dash(
title="decp.info",
use_pages=True,
compress=True,
View File
+41
View File
@@ -0,0 +1,41 @@
import datetime
import os
import polars as pl
import pytest
@pytest.fixture(scope="session", autouse=True)
def test_data():
data = [
{
"uid": "1",
"acheteur_nom": "Acheteur 1",
"acheteur_id": "a1",
"titulaire_nom": "Titulaire 1",
"titulaire_id": "t1",
"montant": 10,
"dateNotification": datetime.date(2025, 1, 1),
"codeCPV": "71600000",
"donneesActuelles": True,
"acheteur_departement_code": "75",
"acheteur_departement_nom": "Paris",
"acheteur_commune_nom": "Paris",
"titulaire_departement_code": "35",
"titulaire_departement_nom": "Ille-et-Vilaine",
"titulaire_commune_nom": "Rennes",
"titulaire_typeIdentifiant": "SIRET",
"objet": "Objet test",
"dureeRestanteMois": 12,
"lieuExecution_code": "75001",
"sourceFile": "test.xml",
"sourceDataset": "test_dataset",
"datePublicationDonnees": datetime.date(2025, 1, 1),
}
]
path = "tests/test.parquet"
path = os.path.abspath(path)
print(f"Writing test data to: {path}") # <-- This will show you the real path
pl.DataFrame(data).write_parquet("tests/test.parquet")
yield path
+31
View File
@@ -0,0 +1,31 @@
from dash.testing.composite import DashComposite
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
def test_001_logo_and_search(dash_duo: DashComposite):
from src.app import app
dash_duo.start_server(app)
dash_duo.wait_for_text_to_equal(".logo > h1", "decp.info", timeout=4)
assert dash_duo.find_element(".logo > h1").text == "decp.info"
search_bar: WebElement = dash_duo.find_element("#search")
search_bar.click()
search_bar.send_keys("A")
search_bar.send_keys(Keys.ENTER)
dash_duo.wait_for_element("#results_acheteur_datatable")
result_table_acheteurs: WebElement = dash_duo.find_element(
"#results_acheteur_datatable tbody"
)
assert (
len(result_table_acheteurs.find_elements(by=By.TAG_NAME, value="tr")) == 2
) # header row + 1 result
assert (
result_table_acheteurs.find_element(
by=By.CSS_SELECTOR, value='td[data-dash-column="acheteur_nom"]'
).text
== "Acheteur 1"
)