Skip to content

Commit

Permalink
github actions pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansurf committed May 25, 2024
1 parent ce93157 commit 6b6f134
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Pytest

on: [push, pull-request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
- name: Test with pytest
run: |
cd src/tests
pytest
33 changes: 18 additions & 15 deletions src/tests/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,36 @@


def test_invalid_input():
with patch("sys.stdout", new=io.StringIO()) as fake_stdout:
extract_decimal(["decimal=NotADecimal"])
printed_output = fake_stdout.getvalue().strip()
assert(
printed_output == "Invalid value for decimal. Please provide an integer."
)
with patch("sys.stdout", new=io.StringIO()) as fake_stdout:
extract_decimal(["decimal=NotADecimal"])
printed_output = fake_stdout.getvalue().strip()
assert printed_output == "Invalid value for decimal. Please provide an integer."


def test_default_input():
decimal = extract_decimal([])
assert 1 == decimal
decimal = extract_decimal([])
assert 1 == decimal


def test_get_coordinates():
coordinates = get_coordinates(["loc=santa_cruz"])
lat = coordinates[0]
long = coordinates[1]
assert(isinstance(lat, (int, float)))
assert(isinstance(long, (int, float)))
assert isinstance(lat, (int, float))
assert isinstance(long, (int, float))


def test_get_uv():
uv = get_uv(37, 122, 2)
assert(isinstance(uv, (int, float)))
assert isinstance(uv, (int, float))


def test_ocean_information():
ocean = ocean_information(37, 122, 2)
assert(isinstance(ocean[0], (int, float)))
assert(isinstance(ocean[1], (int, float)))
assert(isinstance(ocean[2], (int, float)))
assert isinstance(ocean[0], (int, float))
assert isinstance(ocean[1], (int, float))
assert isinstance(ocean[2], (int, float))


def test_main():
"""
Expand All @@ -57,4 +60,4 @@ def test_main():
"""
data_dict = main()
time.sleep(5)
assert(len(data_dict) >= 5)
assert len(data_dict) >= 5

0 comments on commit 6b6f134

Please sign in to comment.