Spaces:
Runtime error
Runtime error
Download tests/verify_view.py from Darshankumarr03/Swift-Query: direct link, hf CLI and curl.
- Browser
- Download file 4.12 kB
-
https://huggingface.co/spaces/Darshankumarr03/Swift-Query/resolve/main/tests/verify_view.py
- Command line
-
hf download hf://spaces/Darshankumarr03/Swift-Query/tests/verify_view.py
-
curl -L -o verify_view.py https://huggingface.co/spaces/Darshankumarr03/Swift-Query/resolve/main/tests/verify_view.py
4.12 kB
| from flask import Flask, session, request | |
| import mongomock | |
| from utils.blueprints import assistant | |
| from utils.blueprints.assistant import assistant_bp | |
| # Patch mongo with mock | |
| assistant.mongo.db = mongomock.MongoClient().db | |
| app = Flask(__name__, template_folder='templates') | |
| app.secret_key = 'test' | |
| app.register_blueprint(assistant_bp) | |
| from flask import Blueprint | |
| admin_bp = Blueprint('admin', __name__) | |
| def logout(): return "Logout" | |
| def login(): return "Login" | |
| app.register_blueprint(admin_bp) | |
| def verify_dashboard_view(): | |
| with app.test_request_context(): | |
| # Setup session | |
| session['user_type'] = 'assistant' | |
| session['role'] = 'data_entry' | |
| session['user_name'] = 'Test Assistant' | |
| # 1. Create Data | |
| # Patient | |
| assistant.mongo.db.patient.insert_one({ | |
| "id": 101, | |
| "sql_id": 101, | |
| "name": "Jane User", | |
| "phone": "555-0100", | |
| "address": "123 Test Lane", | |
| "gender": "Female" | |
| }) | |
| # Medical History | |
| assistant.mongo.db.medicalhistory.insert_one({ | |
| "patient_id": 101, | |
| "condition": "Hypertension", | |
| "diagnosis_date": "2023-01-01", | |
| "notes": "Stable" | |
| }) | |
| # Consultation | |
| assistant.mongo.db.consultation.insert_one({ | |
| "patient_id": 101, | |
| "date": "2023-02-01", | |
| "doctor_name": "Dr. Smith", | |
| "diagnosis": "Checkup" | |
| }) | |
| # 2. Render Dashboard with Patient Selected | |
| with app.test_client() as client: | |
| with client.session_transaction() as sess: | |
| sess['user_type'] = 'assistant' | |
| sess['role'] = 'data_entry' | |
| # Request with patient_id=101 | |
| resp = client.get('/assistant/dashboard/data_entry?patient_id=101') | |
| html = resp.data.decode('utf-8') | |
| checks = { | |
| "Patient Name Pre-fill": 'value="Jane User"' not in html and "Jane User" in html, # Name is not an input, but displayed in header | |
| "Address Pre-fill": 'value="123 Test Lane"' in html, | |
| "Gender Pre-fill": 'value="Female" selected' in html or 'value="Female" selected' in html, | |
| "History List": "Hypertension" in html, | |
| "Consultation List": "Dr. Smith" in html | |
| } | |
| # Additional Layout Checks | |
| if "grid-cols-1 md:grid-cols-2" in html: | |
| print("[PASS] Spacious Layout Detected (grid-cols-2)") | |
| else: | |
| print("[WARN] Spacious Layout NOT Detected") | |
| # Check Default Active Tab | |
| if "Update Patient Profile" in html: | |
| # It's always in HTML, but we want to check if the 'active' class is near it or its parent. | |
| # Since simple string check just checks existence, we assume logic is correct if HTML structure has changed. | |
| # A better check is 'tab-content active' followed closely by 'Update Patient Profile'? | |
| # But parsing generic HTML is hard with regex here. | |
| pass | |
| if "active" in html and "profile" in html: | |
| # Rough check that profile is potentially active | |
| print("[PASS] Profile Tab likely Active") | |
| if "p-4 shadow-sm" in html: | |
| print("[PASS] Large Input Styling Detected") | |
| else: | |
| print("[WARN] Large Input Styling NOT Detected") | |
| all_passed = True | |
| for check, passed in checks.items(): | |
| if passed: | |
| print(f"[PASS] {check}") | |
| else: | |
| print(f"[FAIL] {check}") | |
| all_passed = False | |
| if all_passed: | |
| print("\nAll View/Edit checks passed!") | |
| else: | |
| print("\nSome checks failed.") | |
| if __name__ == "__main__": | |
| verify_dashboard_view() | |