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

Run tests as continuous integration with GitHub Action #110

Merged
merged 9 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run Tests

on: [push]

jobs:
pytest:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: "1.2.2"
- name: install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-asyncio
- name: run pytests
env:
PYTHONPATH: ${{ github.workspace }}
run: pytest
10 changes: 9 additions & 1 deletion field_friend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from . import automations, hardware, interface, localization, log_configuration, vision
from .system import System

__all__ = ['automations', 'hardware', 'interface', 'localization', 'vision', 'log_configuration', 'System']
__all__ = [
'automations',
'hardware',
'interface',
'localization',
'vision',
'log_configuration',
'System',
]
7 changes: 3 additions & 4 deletions tests/test_gnss.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import pytest
from copy import deepcopy


import pytest
import rosys
from conftest import ROBOT_GEO_START_POSITION
from rosys.testing import assert_point, forward
Expand All @@ -21,8 +20,8 @@ def test_shifted_calculation():
point = GeoPoint(lat=51.983159, long=7.434212)
shifted = point.shifted(rosys.geometry.Point(x=6, y=6))
# coordinates should be x pointing north, y pointing west (verified with https://www.meridianoutpost.com/resources/etools/calculators/calculator-latitude-longitude-distance.php?)
assert shifted.lat == 51.98321292429539
assert shifted.long == 7.43412466846196
assert shifted.lat == pytest.approx(51.983212924295)
assert shifted.long == pytest.approx(7.434124668461)
assert_point(shifted.cartesian(point), rosys.geometry.Point(x=6, y=6))


Expand Down
7 changes: 4 additions & 3 deletions tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ async def test_approaching_first_row(system: System, field: Field):
assert system.field_navigation.automation_watcher.field_watch_active


async def test_not_approaching_first_row_when_outside_field(system: System, field: Field):
async def test_approaching_first_row_when_outside_of_field(system: System, field: Field):
async def drive_away():
await system.driver.drive_to(rosys.geometry.Point(x=-5, y=0))
system.automator.start(drive_away())
await forward(22)
await forward(50)
assert not system.automator.is_running

system.field_navigation.field = field
Expand All @@ -78,8 +78,9 @@ async def test_resuming_field_navigation_after_automation_stop(system: System, f
system.automator.start()
assert field.reference
await forward(1) # update gnss reference to use the fields reference
point = rosys.geometry.Point(x=1.50, y=-6.1)
point = rosys.geometry.Point(x=1.54, y=-6.1)
await forward(x=point.x, y=point.y, tolerance=0.01) # drive until we are on first row
await forward(2)
assert system.field_navigation.state == system.field_navigation.State.FOLLOWING_ROW
system.automator.stop(because='test')
await forward(2)
Expand Down
Loading