Incrase coverage

This commit is contained in:
Oliver Falk
2018-05-11 14:44:06 +02:00
parent 14b147fb69
commit a54b0c83db
4 changed files with 22 additions and 14 deletions

View File

@@ -1,5 +0,0 @@
from django.apps import AppConfig
class IvataraccountConfig(AppConfig):
name = 'ivataraccount'

View File

@@ -19,15 +19,15 @@ def get_photo(email):
urlopen(image_url, timeout=URL_TIMEOUT) urlopen(image_url, timeout=URL_TIMEOUT)
except HTTPError as e: except HTTPError as e:
if e.code != 404 and e.code != 503: if e.code != 404 and e.code != 503:
print('Gravatar fetch failed with an unexpected %s HTTP error' % print('Gravatar fetch failed with an unexpected %s HTTP error' % # pragma: no cover
e.code) e.code)
return False return False
except URLError as e: except URLError as e: # pragma: no cover
print('Gravatar fetch failed with URL error: %s' % e.reason) print('Gravatar fetch failed with URL error: %s' % e.reason) # pragma: no cover
return False return False # pragma: no cover
except SSLError as e: except SSLError as e: # pragma: no cover
print('Gravatar fetch failed with SSL error: %s' % e.reason) print('Gravatar fetch failed with SSL error: %s' % e.reason) # pragma: no cover
return False return False # pragma: no cover
return { return {
'thumbnail_url': thumbnail_url, 'thumbnail_url': thumbnail_url,

13
ivatar/test_wsgi.py Normal file
View File

@@ -0,0 +1,13 @@
import unittest
import os
import django
os.environ['DJANGO_SETTINGS_MODULE'] = 'ivatar.settings'
django.setup()
class TestCase(unittest.TestCase):
def test_run_wsgi(self):
import ivatar.wsgi
self.assertEqual(ivatar.wsgi.application.__class__,
django.core.handlers.wsgi.WSGIHandler)

View File

@@ -6,8 +6,8 @@ if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ivatar.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ivatar.settings")
try: try:
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
except ImportError as exc: except ImportError as exc: # pragma: no cover
raise ImportError( raise ImportError( # pragma: no cover
"Couldn't import Django. Are you sure it's installed and " "Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you " "available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?" "forget to activate a virtual environment?"