Skip to content
Open
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
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -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
25 changes: 22 additions & 3 deletions tests/test_catmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

20 changes: 15 additions & 5 deletions tests/test_cattery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand Down
19 changes: 13 additions & 6 deletions tests/test_safecatmath.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)