Skip to content

Reorganize Test Structure and Fix Permission Issues - Move tests/ to Project Root #108

@manavgup

Description

@manavgup

Description

The current test setup has several critical issues that prevent tests from running successfully:

Current Problems:

  1. Permission Error: Tests fail with PermissionError: [Errno 13] Permission denied: '/logs' because the test container tries to create /logs directory without proper permissions
  2. Test Structure: Tests are currently located in backend/tests/ which creates import path issues and makes the test structure confusing
  3. Import Issues: conftest.py imports from main which tries to create log directories during import time
  4. Complex Test Organization: Current structure has 20+ test directories with hundreds of tests and fixtures, making maintenance difficult

Proposed Solution:

  1. Move tests/ to project root (/tests instead of /backend/tests)
  2. Optimize test structure by consolidating related tests and removing redundant fixtures
  3. Fix permission issues by ensuring proper volume mounting and directory permissions
  4. Update Makefile to support both full test runs and targeted test execution
  5. Simplify test organization to focus on core functionality coverage

Required Changes:

1. Directory Structure Changes:

/tests/                          # Move from /backend/tests/
├── conftest.py                 # Updated with proper imports
├── unit/                       # Core unit tests
├── integration/                # Integration tests
├── api/                        # API endpoint tests
├── fixtures/                   # Essential test fixtures only
└── utils/                      # Test utilities

2. Makefile Updates:

  • Add make test testfile=path/to/test.py for specific test files
  • Add make test testfile=path/to/test.py::test_name for specific test functions
  • Update volume mounting to fix permission issues
  • Ensure proper test directory creation

3. Docker Configuration:

  • Update test container to handle log directory permissions properly
  • Fix volume mounting for test reports and source code

4. Import Path Updates:

  • Update all test imports to use new structure
  • Fix conftest.py to avoid importing main application during test setup

Benefits:

  • ✅ All tests will pass without permission errors
  • ✅ Cleaner, more maintainable test structure
  • ✅ Better test isolation and organization
  • ✅ Easier to run specific tests or test suites
  • ✅ Improved CI/CD pipeline reliability

Labels:

  • bug
  • tests
  • refactor
  • docker

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions