-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive test coverage for untested backend functions and web routes #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: realMorgon <81616308+realMorgon@users.noreply.github.com>
- Add tests for user_handler functions (password verification, user retrieval, deletion, team membership) - Add tests for team_handler functions (team retrieval by ID/name, deletion) - Add tests for table_handler functions (table creation/deletion, cell operations, permissions) Co-authored-by: realMorgon <81616308+realMorgon@users.noreply.github.com>
- Remove duplicate pytest marker - Fix UUID conversion logic to use UUID() constructor instead of uuid4() Co-authored-by: realMorgon <81616308+realMorgon@users.noreply.github.com>
- Fix error message pattern to include 'in schema' - Fix delete_table to use actual project_id instead of random UUID Co-authored-by: realMorgon <81616308+realMorgon@users.noreply.github.com>
- Ensure all tests use consistent marker order: data_db first, asyncio second - Matches existing test pattern in test_projects.py Co-authored-by: realMorgon <81616308+realMorgon@users.noreply.github.com>
|
@copilot You may also create new test markers or new testfiles. Make it a priority that tests are easy to understand and if failed the reason is easy to find. You may also edit my tests if there is a need for that. |
- Add helper fixtures to conftest.py for common test setup - Add descriptive assertion messages to all tests for easier debugging - Split large test_table_handler.py into focused files: * test_table_operations.py for table/cell operations * test_table_permissions.py for permission management - Add new pytest markers (table_operations, table_permissions) - Add comprehensive tests/README.md documenting test organization Co-authored-by: realMorgon <81616308+realMorgon@users.noreply.github.com>
I've improved the test organization and clarity in commit d785bee: Test Organization:
Improved Clarity:
Easier Failure Diagnosis:
You can now run focused test groups: |
| async def test_valid_password_with_username(user_db_transaction): | ||
| """Test password validation with username.""" | ||
| # Create a test user | ||
| user_id = await create_user( |
| async def test_valid_password_with_email(user_db_transaction): | ||
| """Test password validation with email.""" | ||
| # Create a test user | ||
| user_id = await create_user( |
|
@copilot Are the tests still in a way the db is reset after? |
Yes, the database is still reset after each test. All tests use the This includes:
Each test runs in complete isolation with a clean database state. |
|
@copilot I see you are using much "str(project_id)". It seems i didn't change all the functions to use UUIDs as parameters. Please take care of this. |
- Update table_handler.py functions to accept UUID directly instead of string * create_table now takes project_id: UUID * set_cell_value now takes project_id: UUID * get_cell_value now takes project_id: UUID - Remove str(project_id) calls from all test files - Add comprehensive web route tests (test_web_routes.py) * Index/homepage tests * Login/logout functionality * Dashboard access control * Error page tests (403, 404, 500) * Static file serving * Middleware and headers - Add @pytest.mark.web marker for web tests - Update tests/README.md with web test documentation Co-authored-by: realMorgon <81616308+realMorgon@users.noreply.github.com>
Fixed in commit d3deb5f: UUID Handling:
Web Tests:
Total test count increased from 36 to 51 tests. |
Added 47 tests (32 backend + 15 web) covering all previously untested backend functions and web application routes, increasing total test count from 4 to 51.
Coverage Added
Backend Functions (32 tests):
user_handler.py (13 tests)
team_handler.py (6 tests)
table_operations.py (8 tests)
table_permissions.py (5 tests)
Web Application (15 tests):
test_web_routes.py
Backend API Improvements
Fixed UUID Handling:
create_table,set_cell_value, andget_cell_valueintable_handler.pyto acceptproject_id: UUIDdirectlystr(project_id)conversions throughout codebaseImplementation
All tests follow existing patterns:
@pytest.mark.user_creation,@pytest.mark.data_db, and@pytest.mark.webmarkers for CI test selection@pytest.mark.asyncioAsyncClientfrom httpx for FastAPI endpoint testingTest Organization & Clarity Improvements
Structured Test Files:
test_table_operations.pyandtest_table_permissions.pytest_web_routes.pyfor comprehensive web application testingEnhanced Debugging:
assert user is not None, f"User {user_id} should be found"Helper Fixtures:
test_user,test_project, andtest_tablefixtures inconftest.pyNew Pytest Markers:
@pytest.mark.table_operations- For table and cell operation tests@pytest.mark.table_permissions- For permission management tests@pytest.mark.web- For web route and UI testspytest -m table_operationsorpytest -m webDocumentation:
tests/README.mddocumenting test structure, markers, best practices, and debugging guidanceExample test structure:
Tests are ready for CI execution with existing database setup.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.