File size: 1,501 Bytes
7f6ef8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Unit Tests for OmniSealBench

This directory contains unit tests for the OmniSealBench application.

## Setup

Before running the tests, make sure you have installed the required dependencies:

```bash
# Install pytest and other testing dependencies
pip install pytest pytest-cov

# If you're using the environment.yml file
conda env update -f backend/environment.yml
```

## Running Tests

To run all tests:

```bash
# From the project root directory
pytest tests/

# With coverage report
pytest tests/ --cov=backend
```

To run a specific test file:

```bash
pytest tests/test_app.py
```

To run a specific test function:

```bash
pytest tests/test_app.py::test_index_route
```

## Test Structure

- `test_app.py`: Tests for the Flask application routes and helper functions
- `conftest.py`: Shared pytest fixtures for all test files
- `__init__.py`: Makes the tests directory a Python package for better test discovery

## Mocking

The tests use `unittest.mock` to mock external dependencies like:
- File operations (reading CSV files)
- API calls (requests.get)
- Database connections

This ensures tests are isolated and don't depend on external services.

## Adding New Tests

When adding new tests:

1. Create a new test file if testing a new module
2. Use descriptive test function names (e.g., `test_data_files_benchmark`)
3. Add docstrings to explain what each test is checking
4. Use fixtures from `conftest.py` when appropriate
5. Mock external dependencies to ensure tests are isolated