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

New PyTest Workflow & Unit Tests improvements #4

Merged
merged 4 commits into from
Jul 26, 2023
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
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
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
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 -r requirements.txt
pip install pytest
- name: Running tests with pytest
run: |
pytest tst
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
matplotlib==3.7.2
numpy==1.24.3
pandas==2.0.3
PyYAML==6.0.1
scikit_learn==1.3.0
scipy>=1.10.1
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from yaml import safe_load

CONFIG_FILE_PATH: str = './config.yaml'
CONFIG_FILE_PATH: str = 'config.yaml'
UTF_8: str = 'utf-8'
MODE: str = 'rt'

Expand Down
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)
2 changes: 1 addition & 1 deletion tst/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from src.config import Config, CONFIG_FILE_PATH

cfg: Config = Config(f"../src/{CONFIG_FILE_PATH}")
cfg: Config = Config(f"src/{CONFIG_FILE_PATH}")


class TestConfig:
Expand Down