-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: ["3.8", "3.9", "3.10"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pip install .[dev] | ||
- name: Test with pytest via coverage | ||
run: | | ||
coverage run -m pytest | ||
coverage report -m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from GOSTnets import calculate_od_raw | ||
from unittest.mock import MagicMock | ||
|
||
|
||
def test_calculateOD_csv(tmp_path): | ||
"""Test the calculateOD_csv function.""" | ||
# Define inputs | ||
G = None | ||
# make test csv files | ||
originCSV = tmp_path / "otest_points.csv" | ||
originCSV.write_text("Lat,Lon\n0,0\n1,1\n2,2\n3,3\n4,4\n5,5\n6,6\n7,7\n8,8\n9,9\n") | ||
destinationCSV = tmp_path / "dtest_points.csv" | ||
destinationCSV.write_text( | ||
"Lat,Lon\n0,0\n1,1\n2,2\n3,3\n4,4\n5,5\n6,6\n7,7\n8,8\n9,9\n" | ||
) | ||
fail_value = 999999 | ||
weight = "length" | ||
calculate_snap = True | ||
# mock the calculateOD_gdf function | ||
calculate_od_raw.calculateOD_gdf = MagicMock(return_value=1) | ||
|
||
# Run the function | ||
result = calculate_od_raw.calculateOD_csv( | ||
G, | ||
originCSV, | ||
destinationCSV=destinationCSV, | ||
fail_value=fail_value, | ||
weight=weight, | ||
calculate_snap=calculate_snap, | ||
) | ||
|
||
# Check the result | ||
assert result == 1 | ||
assert calculate_od_raw.calculateOD_gdf.call_count == 1 |