Metadata-Version: 2.5
Name: pr-imports
Version: 0.5.0
Summary: Add your description here
Requires-Python: >=3.12
Requires-Dist: censusforge>=1.2.3
Requires-Dist: duckdb>=1.4.5
Requires-Dist: ibis-framework[duckdb,postgres]>=12.0.0
Requires-Dist: jp-tools>=0.5.8
Requires-Dist: polars>=1.36.1
Requires-Dist: pyarrow>=25.0.0
Description-Content-Type: text/markdown

# pr-imports

Python package that downloads and processes Puerto Rico international trade data from the Puerto Rico Institute of Statistics (IEPR) and the U.S. Census API. Data is cleaned with Polars and stored as Parquet partitions (`data/raw/<source>/<year>/<month>/`) with change history, and queried with DuckDB. A PostgreSQL/TimescaleDB database (SQLModel + Alembic) holds the HTS code catalog.

## Testing

### Requirements

Run `uv sync` (or enter `devenv shell`). This installs `pytest` and `pytest-cov` as dev dependencies.

### Layout

```text
tests/
├── conftest.py                    # shared fixtures (incl. autouse block_network)
├── unit/
│   ├── test_smoke.py              # basic import/sanity checks
│   ├── test_fixtures.py           # checks that the shared fixtures behave
│   ├── test_partition_df.py       # tests for the partition_df logic
│   └── test_schema_contracts.py   # schema/column contract checks
└── integration/                   # empty for now (see below)
```

### Commands

```bash
uv run pytest                                  # full suite
uv run pytest -m unit                          # unit tests only
uv run pytest tests/unit/test_smoke.py         # one file
uv run pytest tests/unit/test_partition_df.py::TestModifiedRecord::test_old_version_marked_removed_and_new_active   # one test
uv run pytest --cov --cov-report=term-missing  # with coverage
```

devenv shortcuts (extra arguments are forwarded to pytest):

```bash
test        # uv run pytest
test-unit   # uv run pytest -m unit
test-cov    # uv run pytest --cov --cov-report=term-missing
```

Coverage is opt-in (it is not in `addopts`) so the normal run stays fast.

### Known bugs (xfail)

Known bugs are documented as tests marked `xfail(strict=True)`: the test is expected to fail. Show them with:

```bash
uv run pytest -rx
```

When a bug gets fixed, its test reports `XPASS(strict)` and the run **fails**. That is the signal to remove the `xfail` marker so the test becomes a normal regression test.

### Integration tests

There are none yet. They will require TimescaleDB and declared DB dependencies (sqlmodel, alembic, a driver), which is pending a maintainer decision.

### Test isolation

Tests write only to pytest's `tmp_path`, and the network is blocked by the autouse fixture `block_network`.
