From ece72481459e90298e5c5d9b34b2cca51c30d096 Mon Sep 17 00:00:00 2001 From: Elliott Lovell Date: Sun, 9 Dec 2018 15:28:50 -0500 Subject: [PATCH 1/2] First commit --- .gitignore | 3 +++ tests/test_catmath.py | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 56c75ba..d505d01 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ catpy/ # pycharm configuration .idea + +Pipfile +Pipfile.lock diff --git a/tests/test_catmath.py b/tests/test_catmath.py index ced6358..e9f2e52 100644 --- a/tests/test_catmath.py +++ b/tests/test_catmath.py @@ -2,18 +2,20 @@ def test__cat_years_to_hooman_years__middle_age__succeeds(): - assert True + assert catmath.cat_years_to_hooman_years(10) == 50 def test__cat_years_to_hooman_years__less_than_one_year__succeeds(): - assert True + assert catmath.cat_years_to_hooman_years(0.5) == 2.5 def test__cat_years_to_hooman_years__0__returns_0(): - 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__not_leap_yr(): + assert catmath.is_cat_leap_year(2017) is False From 378e70a554d9ee680002be19e3b9998f9df8d04f Mon Sep 17 00:00:00 2001 From: Elliott Lovell Date: Sun, 9 Dec 2018 19:04:21 -0500 Subject: [PATCH 2/2] Second commit --- tests/test_cattery.py | 37 +++++++++++++++++++------------------ tests/test_safecatmath.py | 16 ++++++++++------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/tests/test_cattery.py b/tests/test_cattery.py index b36692c..85a5e18 100644 --- a/tests/test_cattery.py +++ b/tests/test_cattery.py @@ -3,37 +3,38 @@ from catinabox import cattery +@pytest.fixture +def cattery_client(): + return cattery.Cattery() + + ########################################################################### # add_cats ########################################################################### -def test__add_cats__succeeds(): - c = cattery.Cattery() - c.add_cats(["Fluffy", "Snookums"]) - assert c.cats == ["Fluffy", "Snookums"] - assert c.num_cats == 2 +def test__add_cats__succeeds(cattery_client): + cattery_client.add_cats(["Fluffy", "Snookums"]) + assert cattery_client.cats == ["Fluffy", "Snookums"] + assert cattery_client.num_cats == 2 ########################################################################### # remove_cat ########################################################################### -def test__remove_cat__succeeds(): - c = cattery.Cattery() - c.add_cats(["Fluffy", "Junior"]) - c.remove_cat("Fluffy") - assert c.cats == ["Junior"] - assert c.num_cats == 1 +def test__remove_cat__succeeds(cattery_client): + cattery_client.add_cats(["Fluffy", "Junior"]) + cattery_client.remove_cat("Fluffy") + assert cattery_client.cats == ["Junior"] + assert cattery_client.num_cats == 1 -def test__remove_cat__no_cats__fails(): - c = cattery.Cattery() +def test__remove_cat__no_cats__fails(cattery_client): with pytest.raises(cattery.CatNotFound): - c.remove_cat("Fluffles") + cattery_client.remove_cat("Fluffles") -def test__remove_cat__cat_not_in_cattery__fails(): - c = cattery.Cattery() - c.add_cats(["Fluffy"]) +def test__remove_cat__cat_not_in_cattery__fails(cattery_client): + cattery_client.add_cats(["Fluffy"]) with pytest.raises(cattery.CatNotFound): - c.remove_cat("Snookums") + cattery_client.remove_cat("Snookums") diff --git a/tests/test_safecatmath.py b/tests/test_safecatmath.py index 3f85a35..64d89a5 100644 --- a/tests/test_safecatmath.py +++ b/tests/test_safecatmath.py @@ -1,4 +1,4 @@ -# import pytest +import pytest from catinabox import safecatmath @@ -19,17 +19,21 @@ def test__cat_years_to_hooman_years__0__returns_0(): def test__cat_years_to_hooman_years__less_0__raises(): - assert True + with pytest.raises(safecatmath.InvalidAge): + safecatmath.cat_years_to_hooman_years(-1) def test__cat_years_to_hooman_years__older_than_1000__raises(): - 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('3') 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)