diff --git a/pytest.ini b/pytest.ini index bddc2d2..35854a4 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,4 @@ [pytest] -addopts = --cov=catinabox --cov-report=term-missing --pep8 --flakes --mccabe +#addopts = --cov=catinabox --cov-report=term-missing --pep8 --flakes --mccabe +addopts = --cov=catinabox --cov-report=term-missing --flakes --mccabe testpaths = tests catinabox diff --git a/tests/test_catmath.py b/tests/test_catmath.py index ced6358..8c923c5 100644 --- a/tests/test_catmath.py +++ b/tests/test_catmath.py @@ -2,18 +2,37 @@ def test__cat_years_to_hooman_years__middle_age__succeeds(): - assert True + #assert True + assert catmath.cat_years_to_hooman_years(8) == 40 def test__cat_years_to_hooman_years__less_than_one_year__succeeds(): - assert True + #assert True + assert catmath.cat_years_to_hooman_years(0.9) == 4.5 def test__cat_years_to_hooman_years__0__returns_0(): - assert True + #assert True + assert catmath.cat_years_to_hooman_years(0) == 0 # BONUS MATERIAL FOR STEP 2 def test__is_cat_leap_year__succeeds(): assert catmath.is_cat_leap_year(2016) is True + +def test__is_cat_leap_year_fails(): + assert catmath.is_cat_leap_year(2023) is False + +def test__is_cat_leap_year_modulo100_succeeds(): + assert catmath.is_cat_leap_year(2000) is True + +def test__is_cat_leap_year_divisible_by_100_is_not_leap_year(): + assert catmath.is_cat_leap_year(1900) is False + +def test_is_cat_leap_year_modulo400_succeeds(): + assert catmath.is_cat_leap_year(2400) is True + +def test_is_cat_leap_year_modulo4_fails(): + assert catmath.is_cat_leap_year(1806) is False + diff --git a/tests/test_cattery.py b/tests/test_cattery.py index b36692c..70e5a4d 100644 --- a/tests/test_cattery.py +++ b/tests/test_cattery.py @@ -2,14 +2,23 @@ from catinabox import cattery +########################################################################### +# catery_client +########################################################################### + +@pytest.fixture(scope='session') +def cattery_client(): + return ["Fluffy", "Snookums"] + ########################################################################### # add_cats ########################################################################### -def test__add_cats__succeeds(): +def test__add_cats__succeeds(cattery_client): c = cattery.Cattery() - c.add_cats(["Fluffy", "Snookums"]) + #c.add_cats(["Fluffy", "Snookums"]) + c.add_cats(cattery_client) assert c.cats == ["Fluffy", "Snookums"] assert c.num_cats == 2 @@ -18,15 +27,16 @@ def test__add_cats__succeeds(): # remove_cat ########################################################################### -def test__remove_cat__succeeds(): +def test__remove_cat__succeeds(cattery_client): c = cattery.Cattery() - c.add_cats(["Fluffy", "Junior"]) + #c.add_cats(["Fluffy", "Junior"]) + c.add_cats(cattery_client) c.remove_cat("Fluffy") assert c.cats == ["Junior"] assert c.num_cats == 1 -def test__remove_cat__no_cats__fails(): +def test__remove_cat__no_cats__fails(cattery_client): c = cattery.Cattery() with pytest.raises(cattery.CatNotFound): c.remove_cat("Fluffles") diff --git a/tests/test_safecatmath.py b/tests/test_safecatmath.py index 3f85a35..adfbcbf 100644 --- a/tests/test_safecatmath.py +++ b/tests/test_safecatmath.py @@ -1,7 +1,7 @@ # import pytest from catinabox import safecatmath - +import pytest def test__cat_years_to_hooman_years__middle_age__succeeds(): hooman_age = safecatmath.cat_years_to_hooman_years(7) @@ -19,17 +19,24 @@ def test__cat_years_to_hooman_years__0__returns_0(): def test__cat_years_to_hooman_years__less_0__raises(): - assert True + #assert True + with pytest.raises(safecatmath.InvalidAge): + safecatmath.cat_years_to_hooman_years(-10) def test__cat_years_to_hooman_years__older_than_1000__raises(): - assert True + #assert True + with pytest.raises(safecatmath.InvalidAge): + safecatmath.cat_years_to_hooman_years(1001) def test__cat_years_to_hooman_years__string__raises(): - assert True + with pytest.raises(safecatmath.InvalidAge): + safecatmath.cat_years_to_hooman_years('three') + #assert True def test__cat_years_to_hooman_years__nan__raises(): - # hooman_age = float('nan') - assert True + hooman_age = float('nan') + with pytest.raises(safecatmath.InvalidAge): + safecatmath.cat_years_to_hooman_years(hooman_age)