CodeForPhilly / CodeForPhilly/clean-and-green-philly

Task: Add unit testing to the various services

Open
#1,178 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
50
Forks
92
PR merge metrics
No merged PRs in 30d

Description

## Add unit testing to services

We are refactoring the ETL pipeline to avoid using postgres and other changes/refactors. In preparation for that we will be adding testing to the various services.

The testing should follow the example that was added to pwd_parcels. Basically, for the API based services, two separate helper functions should be created for 1) the data transformations within the service and 2) merging. The transformation function should just take a GeoDataFrame (gdf) and the merging functions will usually take in two (primary and the gdf to be merged in). If the transformation function makes changes in place than it shouldn't return a value. These helper functions will allow us to quickly create some sample data and expected results for unit testing these functions.

We may need a different approach for the more ML based services.

The tests should not rely on hitting the API. If sample data from the API is needed, a fixture should be used. If the fixture involves private data (names, addresses), values from Faker should be used instead.

## Acceptance Criteria

- [ ] tests exist for each service
- [ ] helper functions with parameters that allow for easy testing exist for each API based service
- [ ] tests should still work without a internet connection (no APIs are hit) and are true unit tests

## Additional context

This is in preparation for changes in the following tickets:
#1143
#1163

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.