Fix PEP8 warnings
This commit is contained in:
parent
2bc4db1cab
commit
273fa75d55
6 changed files with 100 additions and 74 deletions
|
@ -15,9 +15,11 @@ from membership.models import CustomUser, StripeCustomer
|
||||||
from utils.tests import BaseTestCase
|
from utils.tests import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
from .views import LoginView, SignupView, PasswordResetView, PasswordResetConfirmView,\
|
from .views import (
|
||||||
|
LoginView, SignupView, PasswordResetView, PasswordResetConfirmView,
|
||||||
MembershipPricingView, MembershipPaymentView
|
MembershipPricingView, MembershipPaymentView
|
||||||
from .models import MembershipType, MembershipOrder
|
)
|
||||||
|
from .models import MembershipType
|
||||||
|
|
||||||
|
|
||||||
class ContactViewTest(TestCase):
|
class ContactViewTest(TestCase):
|
||||||
|
@ -41,8 +43,14 @@ class ContactViewTest(TestCase):
|
||||||
|
|
||||||
class ViewsTest(CMSTestCase):
|
class ViewsTest(CMSTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.page1 = create_page('home', 'home_digitalglarus.html', published=True, language='en-us')
|
self.page1 = create_page(
|
||||||
self.page2 = create_page('about', 'about.html', published=True, language='en-us', slug='about')
|
'home', 'home_digitalglarus.html', published=True,
|
||||||
|
language='en-us'
|
||||||
|
)
|
||||||
|
self.page2 = create_page(
|
||||||
|
'about', 'about.html', published=True, language='en-us',
|
||||||
|
slug='about'
|
||||||
|
)
|
||||||
|
|
||||||
def test_digitalglarus_templates(self):
|
def test_digitalglarus_templates(self):
|
||||||
res1 = self.client.get('/en-us/')
|
res1 = self.client.get('/en-us/')
|
||||||
|
@ -69,7 +77,9 @@ class MembershipPricingViewTest(BaseTestCase):
|
||||||
# Anonymous user should get data
|
# Anonymous user should get data
|
||||||
response = self.client.get(self.url)
|
response = self.client.get(self.url)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.context['membership_type'], self.membership_type)
|
self.assertEqual(
|
||||||
|
response.context['membership_type'], self.membership_type
|
||||||
|
)
|
||||||
self.assertTemplateUsed(response, self.expected_template)
|
self.assertTemplateUsed(response, self.expected_template)
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,8 +111,10 @@ class MembershipPaymentViewTest(BaseTestCase):
|
||||||
|
|
||||||
# Anonymous user should get redirect to login
|
# Anonymous user should get redirect to login
|
||||||
response = self.client.get(self.url)
|
response = self.client.get(self.url)
|
||||||
expected_url = "%s?next=%s" % (reverse('digitalglarus:signup'),
|
expected_url = "%s?next=%s" % (
|
||||||
reverse('digitalglarus:membership_payment'))
|
reverse('digitalglarus:signup'),
|
||||||
|
reverse('digitalglarus:membership_payment')
|
||||||
|
)
|
||||||
self.assertRedirects(response, expected_url=expected_url,
|
self.assertRedirects(response, expected_url=expected_url,
|
||||||
status_code=302, target_status_code=200)
|
status_code=302, target_status_code=200)
|
||||||
|
|
||||||
|
@ -132,8 +144,14 @@ class MembershipPaymentViewTest(BaseTestCase):
|
||||||
}
|
}
|
||||||
response = self.customer_client.post(self.url, self.billing_address)
|
response = self.customer_client.post(self.url, self.billing_address)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertTrue(StripeCustomer.objects.filter(user__email=self.customer.email).exists())
|
self.assertTrue(
|
||||||
stripe_customer = StripeCustomer.objects.get(user__email=self.customer.email)
|
StripeCustomer.objects.filter(
|
||||||
|
user__email=self.customer.email
|
||||||
|
).exists()
|
||||||
|
)
|
||||||
|
stripe_customer = StripeCustomer.objects.get(
|
||||||
|
user__email=self.customer.email
|
||||||
|
)
|
||||||
self.assertEqual(stripe_customer.user, self.customer)
|
self.assertEqual(stripe_customer.user, self.customer)
|
||||||
# self.assertTrue(MembershipOrder.objects.filter(customer=stripe_customer).exists())
|
# self.assertTrue(MembershipOrder.objects.filter(customer=stripe_customer).exists())
|
||||||
# membership_order = MembershipOrder.objects.filter(
|
# membership_order = MembershipOrder.objects.filter(
|
||||||
|
@ -216,7 +234,9 @@ class SignupViewTest(TestCase):
|
||||||
self.assertTemplateUsed(response, self.expected_template)
|
self.assertTemplateUsed(response, self.expected_template)
|
||||||
|
|
||||||
def test_anonymous_user_can_signup(self):
|
def test_anonymous_user_can_signup(self):
|
||||||
response = self.client.post(self.url, data=self.signup_data, follow=True)
|
response = self.client.post(
|
||||||
|
self.url, data=self.signup_data, follow=True
|
||||||
|
)
|
||||||
self.user = CustomUser.objects.get(email=self.signup_data.get('email'))
|
self.user = CustomUser.objects.get(email=self.signup_data.get('email'))
|
||||||
self.assertEqual(response.context['user'], self.user)
|
self.assertEqual(response.context['user'], self.user)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
|
@ -13,10 +13,12 @@ from stored_messages.models import Inbox
|
||||||
|
|
||||||
from membership.models import CustomUser, StripeCustomer
|
from membership.models import CustomUser, StripeCustomer
|
||||||
from .models import HostingOrder
|
from .models import HostingOrder
|
||||||
from .views import DjangoHostingView, RailsHostingView, NodeJSHostingView, LoginView, SignupView, \
|
from .views import (
|
||||||
PaymentVMView, OrdersHostingDetailView, OrdersHostingListView, VirtualMachineView, \
|
DjangoHostingView, RailsHostingView, NodeJSHostingView, LoginView,
|
||||||
VirtualMachinesPlanListView, PasswordResetView, PasswordResetConfirmView, HostingPricingView, \
|
SignupView, PaymentVMView, OrdersHostingDetailView, OrdersHostingListView,
|
||||||
NotificationsView, MarkAsReadNotificationView
|
VirtualMachinesPlanListView, PasswordResetView, PasswordResetConfirmView,
|
||||||
|
HostingPricingView, NotificationsView, MarkAsReadNotificationView
|
||||||
|
)
|
||||||
from utils.tests import BaseTestCase
|
from utils.tests import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,15 +54,16 @@ class DjangoHostingViewTest(TestCase, ProcessVMSelectionTestMixin):
|
||||||
self.view = DjangoHostingView()
|
self.view = DjangoHostingView()
|
||||||
self.expected_template = 'hosting/django.html'
|
self.expected_template = 'hosting/django.html'
|
||||||
HOSTING = 'django'
|
HOSTING = 'django'
|
||||||
#configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING)
|
# configuration_detail = dict(
|
||||||
|
# VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING)
|
||||||
self.expected_context = {
|
self.expected_context = {
|
||||||
'hosting': HOSTING,
|
'hosting': HOSTING,
|
||||||
'hosting_long': "Django",
|
'hosting_long': "Django",
|
||||||
#'configuration_detail': configuration_detail,
|
# 'configuration_detail': configuration_detail,
|
||||||
'domain': "django-hosting.ch",
|
'domain': "django-hosting.ch",
|
||||||
'google_analytics': "UA-62285904-6",
|
'google_analytics': "UA-62285904-6",
|
||||||
'email': "info@django-hosting.ch",
|
'email': "info@django-hosting.ch",
|
||||||
#'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
# 'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,15 +79,16 @@ class RailsHostingViewTest(TestCase, ProcessVMSelectionTestMixin):
|
||||||
self.view = RailsHostingView()
|
self.view = RailsHostingView()
|
||||||
self.expected_template = 'hosting/rails.html'
|
self.expected_template = 'hosting/rails.html'
|
||||||
HOSTING = 'rails'
|
HOSTING = 'rails'
|
||||||
#configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING)
|
# configuration_detail = dict(
|
||||||
|
# VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING)
|
||||||
self.expected_context = {
|
self.expected_context = {
|
||||||
'hosting': HOSTING,
|
'hosting': HOSTING,
|
||||||
'hosting_long': "Ruby On Rails",
|
'hosting_long': "Ruby On Rails",
|
||||||
#'configuration_detail': configuration_detail,
|
# 'configuration_detail': configuration_detail,
|
||||||
'domain': "rails-hosting.ch",
|
'domain': "rails-hosting.ch",
|
||||||
'google_analytics': "UA-62285904-5",
|
'google_analytics': "UA-62285904-5",
|
||||||
'email': "info@rails-hosting.ch",
|
'email': "info@rails-hosting.ch",
|
||||||
#'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
# 'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,15 +104,16 @@ class NodeJSHostingViewTest(TestCase, ProcessVMSelectionTestMixin):
|
||||||
self.view = NodeJSHostingView()
|
self.view = NodeJSHostingView()
|
||||||
self.expected_template = 'hosting/nodejs.html'
|
self.expected_template = 'hosting/nodejs.html'
|
||||||
HOSTING = 'nodejs'
|
HOSTING = 'nodejs'
|
||||||
#configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING)
|
# configuration_detail = dict(
|
||||||
|
# VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING)
|
||||||
self.expected_context = {
|
self.expected_context = {
|
||||||
'hosting': HOSTING,
|
'hosting': HOSTING,
|
||||||
'hosting_long': "NodeJS",
|
'hosting_long': "NodeJS",
|
||||||
#'configuration_detail': configuration_detail,
|
# 'configuration_detail': configuration_detail,
|
||||||
'domain': "node-hosting.ch",
|
'domain': "node-hosting.ch",
|
||||||
'google_analytics': "UA-62285904-7",
|
'google_analytics': "UA-62285904-7",
|
||||||
'email': "info@node-hosting.ch",
|
'email': "info@node-hosting.ch",
|
||||||
#'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
# 'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,11 +129,11 @@ class HostingPricingViewTest(TestCase):
|
||||||
self.view = HostingPricingView()
|
self.view = HostingPricingView()
|
||||||
self.expected_template = 'hosting/hosting_pricing.html'
|
self.expected_template = 'hosting/hosting_pricing.html'
|
||||||
|
|
||||||
#configuration_options = dict(VirtualMachinePlan.VM_CONFIGURATION)
|
# configuration_options = dict(VirtualMachinePlan.VM_CONFIGURATION)
|
||||||
self.expected_context = {
|
self.expected_context = {
|
||||||
#'configuration_options': configuration_options,
|
# 'configuration_options': configuration_options,
|
||||||
'email': "info@django-hosting.ch",
|
'email': "info@django-hosting.ch",
|
||||||
#'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
# 'vm_types': VirtualMachineType.get_serialized_vm_types(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def url_resolve_to_view_correctly(self):
|
def url_resolve_to_view_correctly(self):
|
||||||
|
@ -184,7 +189,7 @@ class PaymentVMViewTest(BaseTestCase):
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
|
|
||||||
session = self.customer_client.session
|
# session = self.customer_client.session
|
||||||
# session.update(self.session_data)
|
# session.update(self.session_data)
|
||||||
# session.save()
|
# session.save()
|
||||||
|
|
||||||
|
@ -381,8 +386,8 @@ class VirtualMachinesPlanListViewTest(BaseTestCase):
|
||||||
|
|
||||||
self.stripe_customer = mommy.make(StripeCustomer, user=self.customer)
|
self.stripe_customer = mommy.make(StripeCustomer, user=self.customer)
|
||||||
mommy.make(HostingOrder, customer=self.stripe_customer, approved=True, _quantity=20)
|
mommy.make(HostingOrder, customer=self.stripe_customer, approved=True, _quantity=20)
|
||||||
#_vms = VirtualMachinePlan.objects.all()
|
# _vms = VirtualMachinePlan.objects.all()
|
||||||
#self.vms = sorted(_vms, key=lambda vm: vm.id, reverse=True)
|
# self.vms = sorted(_vms, key=lambda vm: vm.id, reverse=True)
|
||||||
self.url = reverse('hosting:virtual_machines')
|
self.url = reverse('hosting:virtual_machines')
|
||||||
self.view = VirtualMachinesPlanListView()
|
self.view = VirtualMachinesPlanListView()
|
||||||
self.expected_template = 'hosting/virtual_machines.html'
|
self.expected_template = 'hosting/virtual_machines.html'
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
import re
|
# import re
|
||||||
|
|
||||||
from django.test import TestCase
|
# from django.test import TestCase
|
||||||
from django.core.urlresolvers import reverse
|
# from django.core.urlresolvers import reverse
|
||||||
from django.core import mail
|
# from django.core import mail
|
||||||
|
|
||||||
|
|
||||||
class LoginTestCase(TestCase):
|
# class LoginTestCase(TestCase):
|
||||||
def test_login(self):
|
# def test_login(self):
|
||||||
url = reverse('login_glarus')
|
# url = reverse('login_glarus')
|
||||||
res = self.client.post(
|
# res = self.client.post(
|
||||||
url,
|
# url,
|
||||||
data={
|
# data={
|
||||||
'email': 'test@gmail.com',
|
# 'email': 'test@gmail.com',
|
||||||
'password': 'test', 'name':
|
# 'password': 'test', 'name':
|
||||||
'test'}
|
# 'test'}
|
||||||
)
|
# )
|
||||||
#self.assertContains(res, "You\'re successfully registered!", 1, 200)
|
# self.assertContains(res, "You\'re successfully registered!", 1, 200)
|
||||||
#self.assertEqual(len(mail.outbox), 1)
|
# self.assertEqual(len(mail.outbox), 1)
|
||||||
|
#
|
||||||
# validation_url = re.findall(r"http://.*?(/.*)", mail.outbox[0].body)
|
# validation_url = re.findall(r"http://.*?(/.*)", mail.outbox[0].body)
|
||||||
# res1 = self.client.get(validation_url[0] + '/')
|
# res1 = self.client.get(validation_url[0] + '/')
|
||||||
# self.assertContains(res1, "Email verified!", 1, 200)
|
# self.assertContains(res1, "Email verified!", 1, 200)
|
||||||
#
|
#
|
||||||
# res2 = self.client.post(
|
# res2 = self.client.post(
|
||||||
# url, data={'email': 'test@gmail.com', 'password': 'test'}
|
# url, data={'email': 'test@gmail.com', 'password': 'test'}
|
||||||
# )
|
# )
|
||||||
# self.assertEqual(res2.status_code, 302)
|
# self.assertEqual(res2.status_code, 302)
|
||||||
# redirect_location = res2.get('Location')
|
# redirect_location = res2.get('Location')
|
||||||
#
|
#
|
||||||
# res3 = self.client.get(redirect_location)
|
# res3 = self.client.get(redirect_location)
|
||||||
# self.assertContains(res3, 'Pick coworking date.', 1, 200)
|
# self.assertContains(res3, 'Pick coworking date.', 1, 200)
|
||||||
|
#
|
||||||
# check fail login
|
# # check fail login
|
||||||
|
#
|
||||||
# res4 = self.client.post(
|
# res4 = self.client.post(
|
||||||
# url, data={
|
# url, data={
|
||||||
# 'email': 'test@gmail.com', 'password': 'falsepassword'
|
# 'email': 'test@gmail.com', 'password': 'falsepassword'
|
||||||
# }
|
# }
|
||||||
# )
|
# )
|
||||||
# self.assertContains(res4, 'Sorry, that login was invalid.', 1, 200)
|
# self.assertContains(res4, 'Sorry, that login was invalid.', 1, 200)
|
||||||
|
|
|
@ -14,7 +14,7 @@ from utils.models import CustomUser
|
||||||
settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is
|
settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is
|
||||||
"test_domain",
|
"test_domain",
|
||||||
"""OpenNebula details unavailable, so skipping
|
"""OpenNebula details unavailable, so skipping
|
||||||
OpenNebulaManagerTestCases"""
|
OpenNebulaManagerTestCases"""
|
||||||
)
|
)
|
||||||
class OpenNebulaManagerTestCases(TestCase):
|
class OpenNebulaManagerTestCases(TestCase):
|
||||||
"""This class defines the test suite for the opennebula manager model."""
|
"""This class defines the test suite for the opennebula manager model."""
|
||||||
|
@ -127,11 +127,12 @@ class OpenNebulaManagerTestCases(TestCase):
|
||||||
"""Test the opennebula manager requires the user to have a ssh key when
|
"""Test the opennebula manager requires the user to have a ssh key when
|
||||||
creating a new vm"""
|
creating a new vm"""
|
||||||
|
|
||||||
|
|
||||||
@skipIf(
|
@skipIf(
|
||||||
settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is
|
settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is
|
||||||
"test_domain",
|
"test_domain",
|
||||||
"""OpenNebula details unavailable, so skipping
|
"""OpenNebula details unavailable, so skipping
|
||||||
VirtualMachineSerializerTestCase"""
|
VirtualMachineSerializerTestCase"""
|
||||||
)
|
)
|
||||||
class VirtualMachineSerializerTestCase(TestCase):
|
class VirtualMachineSerializerTestCase(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -14,7 +14,7 @@ class GlasfaserMenu(CMSAttachMenu):
|
||||||
nodes = []
|
nodes = []
|
||||||
glasfaser_cms = 'ungleich_page/glasfaser_cms_page.html'
|
glasfaser_cms = 'ungleich_page/glasfaser_cms_page.html'
|
||||||
if (request and request.current_page and
|
if (request and request.current_page and
|
||||||
request.current_page.get_template() == glasfaser_cms):
|
request.current_page.get_template() == glasfaser_cms):
|
||||||
template_context = {
|
template_context = {
|
||||||
"request": request,
|
"request": request,
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ class BaseTestCase(TestCase):
|
||||||
|
|
||||||
# Users
|
# Users
|
||||||
self.customer, self.another_customer = mommy.make(
|
self.customer, self.another_customer = mommy.make(
|
||||||
'membership.CustomUser', validated =1,
|
'membership.CustomUser', validated=1, _quantity=2
|
||||||
_quantity=2)
|
)
|
||||||
self.customer.set_password(self.dummy_password)
|
self.customer.set_password(self.dummy_password)
|
||||||
self.customer.save()
|
self.customer.save()
|
||||||
self.another_customer.set_password(self.dummy_password)
|
self.another_customer.set_password(self.dummy_password)
|
||||||
|
|
Loading…
Reference in a new issue