Premier test UI
This commit is contained in:
@@ -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
|
||||
@@ -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"
|
||||
)
|
||||
Reference in New Issue
Block a user