Skip to content
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

Update tests #117

Merged
merged 27 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5b9cead
update tests for `/files` endpoint
andersy005 Aug 19, 2024
79b54e4
Refactor data formatting in charts.py
andersy005 Aug 19, 2024
fd050ae
Refactor test command in main.yaml to run specific test file
andersy005 Aug 19, 2024
725f4fe
delete unused query_helpers.py
andersy005 Aug 19, 2024
f405e51
fix imports
andersy005 Aug 19, 2024
812ee66
update tests for `/projects` endpoint
andersy005 Aug 19, 2024
9140194
update test_credits.py
andersy005 Aug 19, 2024
3532894
update tests/test_clips.py
andersy005 Aug 19, 2024
f16d6c8
update test_clips.py
andersy005 Aug 19, 2024
2dc5726
update test_sql_helpers
andersy005 Aug 19, 2024
04d0940
update test_charts.py
andersy005 Aug 20, 2024
d534b66
update test_health.py
andersy005 Aug 20, 2024
76e3f9c
update conftest
andersy005 Aug 20, 2024
3d45a1f
add -s to diagnose hanging tests
andersy005 Aug 20, 2024
92d9f5a
remove daily frequencies
andersy005 Aug 20, 2024
6fe42b2
disable stdout print
andersy005 Aug 20, 2024
3be0802
fix test_clips
andersy005 Aug 20, 2024
0323f73
update clips
andersy005 Aug 20, 2024
0e40845
update tests
andersy005 Aug 20, 2024
2d4d778
break test_clip into multiple tests
andersy005 Aug 20, 2024
199624d
update files
andersy005 Aug 20, 2024
06555ee
update sorting function
andersy005 Aug 20, 2024
0690065
Refactor sorting function to support case-insensitive sorting for str…
andersy005 Aug 20, 2024
985b980
update tests
andersy005 Aug 20, 2024
41ee75b
update tests
andersy005 Aug 20, 2024
5e55cc1
Add codecov configuration
andersy005 Aug 20, 2024
cea3b8e
Refactor deployment workflow and update production database
andersy005 Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/fly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ jobs:
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
run: |
flyctl deploy --remote-only --config fly.prod.toml
python update_database.py production https://offsets-db.fly.dev/files

- name: Notify Slack on Failure
if: failure() && (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
Expand Down Expand Up @@ -111,3 +110,8 @@ jobs:
}
]
}

- name: Update Production DB
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
run: |
python update_database.py production https://offsets-db.fly.dev/files
11 changes: 10 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ jobs:

- name: Run tests
run: |
python -m pytest -v
python -m pytest

- name: Upload code coverage to Codecov
uses: codecov/[email protected]
with:
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OffsetsDB-API, is a fastAPI application, designed to integrate and harmonize dat
[![Fly.io Deployment](https://github.com/carbonplan/offsets-db-api/actions/workflows/fly.yml/badge.svg)](https://github.com/carbonplan/offsets-db-api/actions/workflows/fly.yml)
[![Database Update](https://github.com/carbonplan/offsets-db-api/actions/workflows/update-db.yaml/badge.svg)](https://github.com/carbonplan/offsets-db-api/actions/workflows/updated-db.yaml)
![MIT License](https://badgen.net/badge/license/MIT/blue)
[![Code Coverage Status][codecov-badge]][codecov-link]

| Project | GitHub Repo |
| --------------- | ---------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -61,3 +62,6 @@ All the code in this repository is [MIT](https://choosealicense.com/licenses/mit
## about us

CarbonPlan is a non-profit organization that uses data and science for climate action. We aim to improve the transparency and scientific integrity of carbon removal and climate solutions through open data and tools. Find out more at [carbonplan.org](https://carbonplan.org/) or get in touch by [opening an issue](https://github.com/carbonplan/offsets-db/issues/new) or [sending us an email](mailto:[email protected]).

[codecov-badge]: https://img.shields.io/codecov/c/github/carbonplan/offsets-db-api.svg?logo=codecov
[codecov-link]: https://codecov.io/gh/carbonplan/offsets-db-api
23 changes: 23 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
codecov:
require_ci_to_pass: no
max_report_age: off

comment: false

ignore:
- 'tests/*.py'
- 'update_database.py'
- 'load-testing/*.py'
- 'migrations/*.py'
- 'migrations/versions/*.py'

coverage:
precision: 2
round: down
status:
project:
default:
target: 95
informational: true
patch: off
changes: off
9 changes: 6 additions & 3 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ dependencies:
- apscheduler>=3.10.1
- fastapi
- fastparquet
- fsspec
- gunicorn
- httpx
- intake-parquet
- locust==2.20
- pandas
- pandera
- pip
- postgresql
- pyarrow
- pydantic
- pytest
- pytest-cov
Expand All @@ -22,7 +26,6 @@ dependencies:
- ujson
- universal_pathlib
- uvicorn
- postgresql
- locust==2.20
- watchdog
- pip:
- .
2 changes: 1 addition & 1 deletion offsets_db_api/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fastapi_cache import FastAPICache

from offsets_db_api.log import get_logger
from offsets_db_api.query_helpers import _convert_query_params_to_dict
from offsets_db_api.sql_helpers import _convert_query_params_to_dict

logger = get_logger()

Expand Down
264 changes: 0 additions & 264 deletions offsets_db_api/query_helpers.py

This file was deleted.

6 changes: 3 additions & 3 deletions offsets_db_api/routers/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ async def get_credits_by_project_id(
for row in results:
start_date = row.bin
end_date = calculate_end_date(start_date, freq)
formatted_results.append({'start': start_date, 'end': end_date, 'value': row.value})
formatted_results.append({'start': start_date, 'end': end_date, 'value': int(row.value)})

return PaginatedProjectCreditTotals(
pagination=Pagination(
Expand Down Expand Up @@ -701,7 +701,7 @@ async def get_projects_by_credit_totals(
bin_index = bins.index(bin_start)
bin_end = bins[bin_index + 1] if bin_index < len(bins) - 1 else None
formatted_results.append(
{'start': bin_start, 'end': bin_end, 'category': row.category, 'value': row.value}
{'start': bin_start, 'end': bin_end, 'category': row.category, 'value': int(row.value)}
)

logger.info(f'✅ {len(formatted_results)} bins generated')
Expand Down Expand Up @@ -801,7 +801,7 @@ async def get_projects_by_category(

results = session.exec(projects_count_query).fetchall()

formatted_results = [{'category': row.category, 'value': row.value} for row in results]
formatted_results = [{'category': row.category, 'value': int(row.value)} for row in results]

return PaginatedProjectCounts(
data=formatted_results,
Expand Down
Loading
Loading