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
1 change: 1 addition & 0 deletions .pytest_cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
59 changes: 59 additions & 0 deletions .pytest_cache/v/cache/nodeids
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
"tests/test_catactivities.py",
"tests/test_catactivities.py",
"tests/test_catactivities.py",
"tests/test_catactivities.py::test__cat_nap__satisfying_nap",
"tests/test_catactivities.py::test__cat_nap__not_satisfying",
"tests/test_catgenerator.py",
"tests/test_catgenerator.py",
"tests/test_catgenerator.py",
"tests/test_catgenerator.py::test__",
"tests/test_catmath.py",
"tests/test_catmath.py",
"tests/test_catmath.py",
"tests/test_catmath.py::test__cat_years_to_hooman_years__middle_age__succeeds",
"tests/test_catmath.py::test__cat_years_to_hooman_years__less_than_one_year__succeeds",
"tests/test_catmath.py::test__cat_years_to_hooman_years__0__returns_0",
"tests/test_catmath.py::test__is_cat_leap_year__succeeds",
"tests/test_catmath.py::test__is_cat_leap_year_2000__succeeds",
"tests/test_catmath.py::test__is_cat_leap_year_1900__fails",
"tests/test_catmath.py::test__is_cat_leap_year_2002__fails",
"tests/test_cattery.py",
"tests/test_cattery.py",
"tests/test_cattery.py",
"tests/test_cattery.py::test__add_cats__succeeds",
"tests/test_cattery.py::test__remove_cat__succeeds",
"tests/test_cattery.py::test__remove_cat__no_cats__fails",
"tests/test_cattery.py::test__remove_cat__cat_not_in_cattery__fails",
"tests/test_safecatmath.py",
"tests/test_safecatmath.py",
"tests/test_safecatmath.py",
"tests/test_safecatmath.py::test__cat_years_to_hooman_years__middle_age__succeeds",
"tests/test_safecatmath.py::test__cat_years_to_hooman_years__less_than_one_year__succeeds",
"tests/test_safecatmath.py::test__cat_years_to_hooman_years__0__returns_0",
"tests/test_safecatmath.py::test__cat_years_to_hooman_years__less_0__raises",
"tests/test_safecatmath.py::test__cat_years_to_hooman_years__older_than_1000__raises",
"tests/test_safecatmath.py::test__cat_years_to_hooman_years__string__raises",
"tests/test_safecatmath.py::test__cat_years_to_hooman_years__nan__raises",
"catinabox/__init__.py",
"catinabox/__init__.py",
"catinabox/__init__.py",
"catinabox/catactivities.py",
"catinabox/catactivities.py",
"catinabox/catactivities.py",
"catinabox/catgenerator.py",
"catinabox/catgenerator.py",
"catinabox/catgenerator.py",
"catinabox/catmath.py",
"catinabox/catmath.py",
"catinabox/catmath.py",
"catinabox/cattery.py",
"catinabox/cattery.py",
"catinabox/cattery.py",
"catinabox/mccattery.py",
"catinabox/mccattery.py",
"catinabox/mccattery.py",
"catinabox/safecatmath.py",
"catinabox/safecatmath.py",
"catinabox/safecatmath.py"
]
50 changes: 50 additions & 0 deletions .pytest_cache/v/flakes/mtimes
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"catinabox/__init__.py": [
1527968854.1161103,
[]
],
"catinabox/catactivities.py": [
1527968854.1201196,
[]
],
"catinabox/catgenerator.py": [
1527968854.1251335,
[]
],
"catinabox/catmath.py": [
1527974091.0336118,
[]
],
"catinabox/cattery.py": [
1527968854.1331818,
[]
],
"catinabox/mccattery.py": [
1527968854.1371648,
[]
],
"catinabox/safecatmath.py": [
1527968854.1412032,
[]
],
"tests/test_catactivities.py": [
1528033436.5026548,
[]
],
"tests/test_catgenerator.py": [
1527968854.4336014,
[]
],
"tests/test_catmath.py": [
1527974087.8107457,
[]
],
"tests/test_cattery.py": [
1528031199.9464488,
[]
],
"tests/test_safecatmath.py": [
1528023328.4403205,
[]
]
}
50 changes: 50 additions & 0 deletions .pytest_cache/v/mccabe/mtimes
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/__init__.py": [
1527968854.1161103,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catactivities.py": [
1527968854.1201196,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catgenerator.py": [
1527968854.1251335,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catmath.py": [
1527974091.0336118,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/cattery.py": [
1527968854.1331818,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/mccattery.py": [
1527968854.1371648,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/safecatmath.py": [
1527968854.1412032,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catactivities.py": [
1528033436.5026548,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catgenerator.py": [
1527968854.4336014,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catmath.py": [
1527974087.8107457,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [
1528031199.9464488,
7
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [
1528023328.4403205,
7
]
}
50 changes: 50 additions & 0 deletions .pytest_cache/v/pep8/mtimes
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/__init__.py": [
1527968854.1161103,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catactivities.py": [
1527968854.1201196,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catgenerator.py": [
1527968854.1251335,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/catmath.py": [
1527974091.0336118,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/cattery.py": [
1527968854.1331818,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/mccattery.py": [
1527968854.1371648,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/catinabox/safecatmath.py": [
1527968854.1412032,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catactivities.py": [
1528033436.5026548,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catgenerator.py": [
1527968854.4336014,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_catmath.py": [
1527974087.8107457,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_cattery.py": [
1528031199.9464488,
[]
],
"/mnt/c/Users/rowan/Work/Python/Learning/Pytest/catinabox/tests/test_safecatmath.py": [
1528023328.4403205,
[]
]
}
6 changes: 3 additions & 3 deletions catinabox/catmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def is_cat_leap_year(year):
bool: True iff. the cat year is a leap cat year.

"""
if year % 4 != 0:
if (year % 4) != 0:
return False
elif year % 100 != 0:
elif (year % 400) == 0:
return True
elif year % 400 != 0:
elif (year % 100) == 0:
return False
else:
return True
17 changes: 10 additions & 7 deletions tests/test_catactivities.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# import pytest
# import time
import pytest
import time

# from catinabox import catactivities
from catinabox import catactivities


def test__cat_nap__satisfying_nap(mocker):
# mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
assert True
mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
catactivities.cat_nap(500)
mock_sleep.assert_called_with(500)


def test__cat_nap__not_satisfying(mocker):
# mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
assert True
mock_sleep = mocker.patch.object(time, "sleep", autospec=True)
with pytest.raises(catactivities.NapWillNotBeSatisfying):
catactivities.cat_nap(299)
mock_sleep.assert_not_called()
16 changes: 13 additions & 3 deletions tests/test_catmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@


def test__cat_years_to_hooman_years__middle_age__succeeds():
assert True
expected = 50
result = catmath.cat_years_to_hooman_years(10)
assert expected == result


def test__cat_years_to_hooman_years__less_than_one_year__succeeds():
assert True
expected = 2.5
result = catmath.cat_years_to_hooman_years(0.5)
assert expected == result


def test__cat_years_to_hooman_years__0__returns_0():
assert True
expected = 0
result = catmath.cat_years_to_hooman_years(0)
assert expected == result


# BONUS MATERIAL FOR STEP 2

def test__is_cat_leap_year__succeeds():
assert catmath.is_cat_leap_year(3) is False
assert catmath.is_cat_leap_year(2016) is True
assert catmath.is_cat_leap_year(4) is True
assert catmath.is_cat_leap_year(100) is False
assert catmath.is_cat_leap_year(400) is True
37 changes: 19 additions & 18 deletions tests/test_cattery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
18 changes: 13 additions & 5 deletions tests/test_safecatmath.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# import pytest

from catinabox import safecatmath
import pytest


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


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


def test__cat_years_to_hooman_years__string__raises():
assert True
with pytest.raises(safecatmath.InvalidAge):
cat_age = 'one'
assert safecatmath.cat_years_to_hooman_years(cat_age)


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