Skip to content

Commit

Permalink
Added pytest workflow and enhanced some Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-florentin-charles committed Jul 26, 2023
1 parent 20be773 commit ae963b7
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Pylint

on: [push]
on: [push, pull_request]

jobs:
build:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pylint

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Running tests with pytest
run: |
pytest tst
4 changes: 2 additions & 2 deletions src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def run() -> None:
:return: None
"""
by_year: bool = False
by_year: bool = True
by_month: bool = False

month: Month = Month.JULY
season: Season = Season.FALL
season: Season = Season.SUMMER

if by_year:
yearly_rainfall: YearlyRainfall = YearlyRainfall()
Expand Down
92 changes: 88 additions & 4 deletions tst/enums/test_months.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,92 @@
from src.enums.months import Month


def test_months() -> None:
assert len(Month) == 12
class TestMonths:

month: Month = Month.MAY
assert month.value == 5
@staticmethod
def test_months_count() -> None:
assert len(Month) == 12

@staticmethod
def test_january() -> None:
month: Month = Month.JANUARY

assert isinstance(month.value, int)
assert month.value == 1

@staticmethod
def test_february() -> None:
month: Month = Month.FEBRUARY

assert isinstance(month.value, int)
assert month.value == 2

@staticmethod
def test_march() -> None:
month: Month = Month.MARCH

assert isinstance(month.value, int)
assert month.value == 3

@staticmethod
def test_april() -> None:
month: Month = Month.APRIL

assert isinstance(month.value, int)
assert month.value == 4

@staticmethod
def test_may() -> None:
month: Month = Month.MAY

assert isinstance(month.value, int)
assert month.value == 5

@staticmethod
def test_june() -> None:
month: Month = Month.JUNE

assert isinstance(month.value, int)
assert month.value == 6

@staticmethod
def test_july() -> None:
month: Month = Month.JULY

assert isinstance(month.value, int)
assert month.value == 7

@staticmethod
def test_august() -> None:
month: Month = Month.AUGUST

assert isinstance(month.value, int)
assert month.value == 8

@staticmethod
def test_september() -> None:
month: Month = Month.SEPTEMBER

assert isinstance(month.value, int)
assert month.value == 9

@staticmethod
def test_october() -> None:
month: Month = Month.OCTOBER

assert isinstance(month.value, int)
assert month.value == 10

@staticmethod
def test_november() -> None:
month: Month = Month.NOVEMBER

assert isinstance(month.value, int)
assert month.value == 11

@staticmethod
def test_december() -> None:
month: Month = Month.DECEMBER

assert isinstance(month.value, int)
assert month.value == 12
45 changes: 39 additions & 6 deletions tst/enums/test_seasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,43 @@
from src.enums.seasons import Season


def test_seasons() -> None:
assert len(Season) == 4
class TestSeasons:
@staticmethod
def test_seasons_count() -> None:
assert len(Season) == 4

season: Season = Season.WINTER
assert isinstance(season.value, list)
assert len(season.value) == 3
assert isinstance(season.value[0], Month)
@staticmethod
def test_winter() -> None:
season: Season = Season.WINTER

assert isinstance(season.value, list)
assert len(season.value) == 3
for month in season.value:
assert isinstance(month, Month)

@staticmethod
def test_spring() -> None:
season: Season = Season.SPRING

assert isinstance(season.value, list)
assert len(season.value) == 3
for month in season.value:
assert isinstance(month, Month)

@staticmethod
def test_summer() -> None:
season: Season = Season.SUMMER

assert isinstance(season.value, list)
assert len(season.value) == 3
for month in season.value:
assert isinstance(month, Month)

@staticmethod
def test_fall() -> None:
season: Season = Season.FALL

assert isinstance(season.value, list)
assert len(season.value) == 3
for month in season.value:
assert isinstance(month, Month)

0 comments on commit ae963b7

Please sign in to comment.