gva/gnuviechadmin/gvawebcore/tests/test_views.py
Jan Dittberner 28fc535f9e Add tests for gvawebcore
This commit adds tests for gvawebcore.forms and gvawebcore.views.
2015-11-22 14:43:02 +00:00

34 lines
1 KiB
Python

"""
This model contains tests for :py:mod:`gvawebcore.views`.
"""
from unittest import TestCase
from mock import patch, Mock
from gvawebcore.views import HostingPackageAndCustomerMixin
class HostingPackageAndCustomerMixinTest(TestCase):
class TestView(HostingPackageAndCustomerMixin):
kwargs = {'package': '1'}
@patch('gvawebcore.views.get_object_or_404')
def test_get_hosting_package(self, get_object_or_404):
get_object_or_404.return_value = 'A package'
view = self.TestView()
self.assertEqual('A package', view.get_hosting_package())
def test_get_hosting_package_cached(self):
view = self.TestView()
view.hostingpackage = 'Cached package'
self.assertEqual('Cached package', view.get_hosting_package())
@patch('gvawebcore.views.get_object_or_404')
def test_get_customer_object(self, get_object_or_404):
get_object_or_404.return_value = Mock(customer='A customer')
view = self.TestView()
self.assertEqual('A customer', view.get_customer_object())