From b155fa2c3925552493a0da3e6dce55f06e6f810f Mon Sep 17 00:00:00 2001 From: faruklmu17 Date: Fri, 3 Apr 2026 11:22:31 -0400 Subject: [PATCH 1/3] Add architecture skeleton for data validation --- README.md | 2 +- conftest.py | 13 +++++++++ data_clients/db_client.py | 16 +++++++++++ data_driven_test.py | 35 +++++++++++++++++++++++ requirements.txt | 3 ++ tests/data_quality/test_data_anomalies.py | 14 +++++++++ users.csv | 4 +++ utils/data_validation/dataframe_utils.py | 17 +++++++++++ 8 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 data_clients/db_client.py create mode 100644 data_driven_test.py create mode 100644 tests/data_quality/test_data_anomalies.py create mode 100644 users.csv create mode 100644 utils/data_validation/dataframe_utils.py diff --git a/README.md b/README.md index 97d3b67..bbd79f9 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ A modular, pytest-based **Playwright (Python)** framework for web UI testing. ``` > Tip: to **watch it in a real browser**, run headed: > ```bash - > HEADLESS=false pytest -s tests/test_logged_in_session.py + > HEADLESS=false pytest -s tests/test_logged_in.py > ``` 5. **Run the full suite** diff --git a/conftest.py b/conftest.py index 3195f63..86da096 100644 --- a/conftest.py +++ b/conftest.py @@ -104,3 +104,16 @@ def page(context): yield p finally: p.close() + +# --- Database & Data Validation Lifecycle --- + +@pytest.fixture(scope="session") +def db_engine(): + """ + Spawns a mock SQLAlchemy engine structure for backend integration and DataFrame testing. + e.g., engine = sqlalchemy.create_engine('sqlite:///:memory:') + """ + # engine = None + # yield engine + # engine.dispose() + yield "mock_engine_connection" diff --git a/data_clients/db_client.py b/data_clients/db_client.py new file mode 100644 index 0000000..3397fbb --- /dev/null +++ b/data_clients/db_client.py @@ -0,0 +1,16 @@ +class DatabaseClient: + def __init__(self, engine): + self.engine = engine + + def get_user_data(self, user_id): + """ + Skeleton method to return a DataFrame of user data. + In reality, this would use pandas.read_sql or SQLAlchemy. + """ + pass + + def get_system_snapshot(self, system_name): + """ + Skeleton method to pull large-scale dataset snapshots. + """ + pass diff --git a/data_driven_test.py b/data_driven_test.py new file mode 100644 index 0000000..4bb2f5e --- /dev/null +++ b/data_driven_test.py @@ -0,0 +1,35 @@ +def run_signup_from_csv(csv_path="users.csv", headed=True): + import csv + from pathlib import Path + from playwright.sync_api import sync_playwright, expect + + URL = "https://faruk-hasan.com/automation/signup.html" + rows = list(csv.DictReader(Path(csv_path).open(newline="", encoding="utf-8"))) + + with sync_playwright() as pw: + browser = pw.chromium.launch(headless=not headed) + context = browser.new_context() + + for u in rows: + page = context.new_page() + try: + page.goto(URL, wait_until="domcontentloaded") + expect(page).to_have_title("Sign Up - Automation Practice") + + page.locator("#username").fill(u["name"].strip()) + page.locator("#email").fill(u["email"].strip()) + page.locator("#password").fill(u["password"].strip()) + page.locator("#confirmPassword").fill(u["password"].strip()) + page.get_by_role("button", name="Sign Up").click() + + # Let any redirect/JS complete before closing this page + page.wait_for_load_state("networkidle", timeout=7000) + print(f"✅ Signed up: {u['name']} ({u['email']})") + finally: + page.close() + + browser.close() + + +if __name__ == "__main__": + run_signup_from_csv("users.csv", headed=True) diff --git a/requirements.txt b/requirements.txt index b3049ae..1b5d27a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,6 @@ pytest>=8.0.0 playwright>=1.45.0 pytest-playwright>=0.5.0 python-dotenv>=1.0.1 +pandas>=2.0.0 +numpy>=1.24.0 +SQLAlchemy>=2.0.0 diff --git a/tests/data_quality/test_data_anomalies.py b/tests/data_quality/test_data_anomalies.py new file mode 100644 index 0000000..9f1c3af --- /dev/null +++ b/tests/data_quality/test_data_anomalies.py @@ -0,0 +1,14 @@ +import pytest +from utils.data_validation.dataframe_utils import DataFrameValidator +from data_clients.db_client import DatabaseClient + +def test_large_scale_data_stability(db_engine): + """ + A skeleton test representing a data stability check. + It expects the 'db_engine' fixture from conftest.py. + """ + # client = DatabaseClient(db_engine) + # df = client.get_system_snapshot("production_replica") + # validator = DataFrameValidator() + # validator.assert_no_anomalies(df) + pass diff --git a/users.csv b/users.csv new file mode 100644 index 0000000..e27ba00 --- /dev/null +++ b/users.csv @@ -0,0 +1,4 @@ +name,email,password +Admin,admin@example.com,Pass123 +User,user@example.com,Pass456 +Manager,manager@example.com,Pass789 \ No newline at end of file diff --git a/utils/data_validation/dataframe_utils.py b/utils/data_validation/dataframe_utils.py new file mode 100644 index 0000000..449b755 --- /dev/null +++ b/utils/data_validation/dataframe_utils.py @@ -0,0 +1,17 @@ +import pandas as pd +import numpy as np + +class DataFrameValidator: + @staticmethod + def assert_no_anomalies(df: pd.DataFrame, threshold: float = 0.05): + """ + Checks if the number of nulls exceeds a threshold. + """ + pass + + @staticmethod + def compare_snapshots(pre_df: pd.DataFrame, post_df: pd.DataFrame) -> pd.DataFrame: + """ + Returns a diff between pre-code and post-code system states. + """ + pass From c7a518fd6dfd37cfb7f190f35be03e494f791c8b Mon Sep 17 00:00:00 2001 From: faruklmu17 Date: Wed, 24 Jun 2026 13:09:05 -0400 Subject: [PATCH 2/3] Updated readme.md file --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bbd79f9..a31fbd1 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ A modular, pytest-based **Playwright (Python)** framework for web UI testing. ``` 3. **Bootstrap once (signup → login → save session)** + > **Note:** This step is recommended but not required — if `storage_state.json` is missing, pytest will automatically bootstrap the session before running any tests. ```bash python -m scripts.bootstrap_signup --name "Jane Doe" --email "jane@example.com" --password "StrongPass123" ``` From 3483b221ad31b40933a134e50a8d804f0db70711 Mon Sep 17 00:00:00 2001 From: faruklmu17 Date: Tue, 8 Sep 2026 20:36:54 -0400 Subject: [PATCH 3/3] updated --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a31fbd1..fccb58b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ A modular, pytest-based **Playwright (Python)** framework for web UI testing. 3. **Bootstrap once (signup → login → save session)** > **Note:** This step is recommended but not required — if `storage_state.json` is missing, pytest will automatically bootstrap the session before running any tests. + ```bash python -m scripts.bootstrap_signup --name "Jane Doe" --email "jane@example.com" --password "StrongPass123" ```