Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed May 10, 2016
1 parent 8a6d99f commit 3650362
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ script:
- "py.test --cov=itunesiap -vv tests/"
after_success:
- "coveralls"
- bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
matrix:
allow_failures:
- python:
Expand Down
2 changes: 1 addition & 1 deletion itunesiap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

__version__ = pkg_resources.resource_string('itunesiap', 'version.txt').strip()
if PY3:
__version__ = __version__.decode('ascii')
__version__ = __version__.decode('ascii') # pragma: no cover
VERSION = tuple(int(v) for v in __version__.split('.'))

__all__ = (
Expand Down
2 changes: 1 addition & 1 deletion itunesiap/receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, data):
self._ = data

def __repr__(self):
return u'<{}({})>'.format(self.__class__.__name__, self._)
return u'<{0}({1})>'.format(self.__class__.__name__, self._)

def __getitem__(self, item):
return self._[item]
Expand Down
2 changes: 1 addition & 1 deletion itunesiap/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def deprecated(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
warnings.warn_explicit(
"Call to deprecated function {}.".format(func.__name__),
"Call to deprecated function {0}.".format(func.__name__),
category=UserWarning,
filename=func.func_code.co_filename,
lineno=func.func_code.co_firstlineno + 1
Expand Down
21 changes: 18 additions & 3 deletions tests/v2_test.py → tests/itunesiap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ def test_ssl_request_fail():
assert type(e['exc']) == requests.exceptions.SSLError


def test_invalid_receipt():
request = itunesiap.Request('wrong receipt')

with itunesiap.env.production:
with pytest.raises(itunesiap.exc.InvalidReceipt):
request.verify()

with itunesiap.env.sandbox:
with pytest.raises(itunesiap.exc.InvalidReceipt):
request.verify()


@pytest.mark.parametrize("sandbox_receipt", [LEGACY_RAW_RECEIPT])
def test_context(sandbox_receipt):
"""Test sandbox receipts with real itunes server."""
Expand Down Expand Up @@ -255,10 +267,13 @@ def test_date():
assert d.tzinfo == pytz.timezone('America/Los_Angeles')


def test_repr():
@pytest.mark.parametrize("object", [
itunesiap.Request('DummyReceipt'),
itunesiap.Response('{}'),
])
def test_repr(object):
"""Test __repr__"""
request = itunesiap.Request('DummyReceipt')
'{0!r}'.format(request)
'{0!r}'.format(object)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from itunesiap.legacy import exceptions


from tests.v2_test import LEGACY_RAW_RECEIPT
from tests.itunesiap_test import LEGACY_RAW_RECEIPT


class TestsIAP(unittest.TestCase):
Expand Down

0 comments on commit 3650362

Please sign in to comment.