Skip to content

Add tests for cattery #179

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
11 changes: 7 additions & 4 deletions tests/test_catmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@


def test__cat_years_to_hooman_years__middle_age__succeeds():
assert True
cat_years = 10
human_years = catmath.cat_years_to_hooman_years(cat_years)
assert human_years == 50


def test__cat_years_to_hooman_years__less_than_one_year__succeeds():
assert True
cat_years = 0.5
human_years = catmath.cat_years_to_hooman_years(cat_years)
assert human_years == 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
36 changes: 18 additions & 18 deletions tests/test_cattery.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
###########################################################################
# add_cats
###########################################################################
@pytest.fixture(scope='function')
def cattery_client():
return cattery.Cattery()

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")
16 changes: 10 additions & 6 deletions tests/test_safecatmath.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# import pytest
import pytest

from catinabox import safecatmath
from catinabox.safecatmath import InvalidAge


def test__cat_years_to_hooman_years__middle_age__succeeds():
Expand All @@ -19,17 +20,20 @@ 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(InvalidAge):
safecatmath.cat_years_to_hooman_years(-1)


def test__cat_years_to_hooman_years__older_than_1000__raises():
assert True
with pytest.raises(InvalidAge):
safecatmath.cat_years_to_hooman_years(1001)


def test__cat_years_to_hooman_years__string__raises():
assert True
with pytest.raises(InvalidAge):
safecatmath.cat_years_to_hooman_years('str')


def test__cat_years_to_hooman_years__nan__raises():
# hooman_age = float('nan')
assert True
with pytest.raises(InvalidAge):
safecatmath.cat_years_to_hooman_years(float('nan'))