Skip to content

Commit

Permalink
Reto #26 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Pinilla authored and Javier Pinilla committed Jun 28, 2023
1 parent 34b6424 commit d4c3be2
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Retos/Reto #26 - TESTING [Media]/python/ingjavierpinilla.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import unittest
from datetime import datetime


def has_friday_13(year: int, month: int) -> bool:
"""Esta funcion retorna verdadero si para un año y mes dado existe un viernes 13
Args:
year (int):
month (int):
Returns:
bool:
"""
if not isinstance(year, int):
raise TypeError("Year invalid, enter a valid integer number")
if not isinstance(month, int):
raise TypeError("Month invalid, enter a valid integer number")

return datetime(year, month, 13).weekday() == 4


class TestIsFriday13(unittest.TestCase):
def setUp(self):
self.is_friday_13 = {"year": 2023, "month": 10}
self.not_friday_13 = {"year": 2023, "month": 7}

def test_invalid_year(self):
with self.assertRaises(TypeError):
has_friday_13(year="1520", month=7)

def test_invalid_month(self):
with self.assertRaises(TypeError):
has_friday_13(year=1520, month=(1520, 1))

def test_expected_return(self):
self.assertIsInstance(has_friday_13(year=1520, month=7), bool)

def test_valid_friday_13(self):
self.assertIs(
has_friday_13(
year=self.is_friday_13["year"], month=self.is_friday_13["month"]
),
True,
)

def test_invalid_friday_13(self):
self.assertIsNot(
has_friday_13(
year=self.not_friday_13["year"], month=self.not_friday_13["month"]
),
True,
)

if __name__ == "__main__":
unittest.main()

0 comments on commit d4c3be2

Please sign in to comment.