|
| 1 | +<!-- README.md --> |
1 | 2 |  |
2 | 3 |
|
3 | 4 | # PyRetailScience |
@@ -208,3 +209,68 @@ Built with expertise doing analytics and data science for scale-ups to multi-nat |
208 | 209 | ## License |
209 | 210 |
|
210 | 211 | This project is licensed under the Elastic License 2.0 - see the [LICENSE](LICENSE) file for details. |
| 212 | + |
| 213 | +# BigQuery Integration Tests |
| 214 | + |
| 215 | +## Overview |
| 216 | + |
| 217 | +This directory contains integration tests that verify all PyRetailScience analysis modules |
| 218 | +work correctly with Google BigQuery as a backend. These tests confirm that the Ibis-based |
| 219 | +code paths function correctly when connected to BigQuery. |
| 220 | + |
| 221 | +## Test Coverage |
| 222 | + |
| 223 | +The integration tests cover the analysis modules. |
| 224 | + |
| 225 | +## Prerequisites |
| 226 | + |
| 227 | +To run these tests, you need: |
| 228 | + |
| 229 | +1. Access to a Google Cloud Platform account |
| 230 | +2. A service account with BigQuery permissions |
| 231 | +3. The service account key JSON file |
| 232 | +4. The test dataset must be loaded in BigQuery (dataset: `test_data`, table: `transactions`) |
| 233 | + |
| 234 | +## Running the Tests |
| 235 | + |
| 236 | +### Manual Setup |
| 237 | + |
| 238 | +- Set up authentication: |
| 239 | + |
| 240 | +```bash |
| 241 | +export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-key.json |
| 242 | +export GCP_PROJECT_ID=your-project-id |
| 243 | +``` |
| 244 | + |
| 245 | +- Install dependencies: |
| 246 | + |
| 247 | +```bash |
| 248 | +uv sync |
| 249 | +``` |
| 250 | + |
| 251 | +- Run the tests: |
| 252 | + |
| 253 | +```bash |
| 254 | +# Run all tests |
| 255 | +uv run pytest tests/integration/bigquery -v |
| 256 | + |
| 257 | +# Run specific test module |
| 258 | +uv run pytest tests/integration/bigquery/test_cohort_analysis.py -v |
| 259 | +``` |
| 260 | + |
| 261 | +## Using GitHub Actions |
| 262 | + |
| 263 | +These tests can be run manually in GitHub Actions via the "BigQuery Integration Tests" workflow. To run: |
| 264 | + |
| 265 | +1. Go to the "Actions" tab in the GitHub repository |
| 266 | +2. Select the "BigQuery Integration Tests" workflow |
| 267 | +3. Click "Run workflow" |
| 268 | +4. Optionally enter a test filter pattern (e.g., "test_cohort_analysis") |
| 269 | +5. Click "Run workflow" |
| 270 | + |
| 271 | +### Required Secrets |
| 272 | + |
| 273 | +To run the workflow in GitHub Actions, add these secrets to your repository: |
| 274 | + |
| 275 | +- `GCP_SA_KEY`: The entire JSON content of your GCP service account key file |
| 276 | +- `GCP_PROJECT_ID`: Your GCP project ID |
0 commit comments