2015-11-22 15:43:02 +01:00
|
|
|
"""
|
|
|
|
This model contains tests for :py:mod:`gvawebcore.views`.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
from unittest import TestCase
|
2019-01-30 21:27:25 +01:00
|
|
|
from unittest.mock import Mock, patch
|
2015-11-22 15:43:02 +01:00
|
|
|
|
|
|
|
from gvawebcore.views import HostingPackageAndCustomerMixin
|
|
|
|
|
|
|
|
|
|
|
|
class HostingPackageAndCustomerMixinTest(TestCase):
|
|
|
|
class TestView(HostingPackageAndCustomerMixin):
|
|
|
|
|
2019-01-30 21:27:25 +01:00
|
|
|
kwargs = {"package": "1"}
|
2015-11-22 15:43:02 +01:00
|
|
|
|
2019-01-30 21:27:25 +01:00
|
|
|
@patch("gvawebcore.views.get_object_or_404")
|
2015-11-22 15:43:02 +01:00
|
|
|
def test_get_hosting_package(self, get_object_or_404):
|
2019-01-30 21:27:25 +01:00
|
|
|
get_object_or_404.return_value = "A package"
|
2015-11-22 15:43:02 +01:00
|
|
|
view = self.TestView()
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual("A package", view.get_hosting_package())
|
2015-11-22 15:43:02 +01:00
|
|
|
|
|
|
|
def test_get_hosting_package_cached(self):
|
|
|
|
view = self.TestView()
|
2019-01-30 21:27:25 +01:00
|
|
|
view.hostingpackage = "Cached package"
|
|
|
|
self.assertEqual("Cached package", view.get_hosting_package())
|
2015-11-22 15:43:02 +01:00
|
|
|
|
2019-01-30 21:27:25 +01:00
|
|
|
@patch("gvawebcore.views.get_object_or_404")
|
2015-11-22 15:43:02 +01:00
|
|
|
def test_get_customer_object(self, get_object_or_404):
|
2019-01-30 21:27:25 +01:00
|
|
|
get_object_or_404.return_value = Mock(customer="A customer")
|
2015-11-22 15:43:02 +01:00
|
|
|
view = self.TestView()
|
2019-01-30 21:27:25 +01:00
|
|
|
self.assertEqual("A customer", view.get_customer_object())
|