Fix PEP8 warnings

This commit is contained in:
PCoder 2017-11-26 01:12:16 +01:00
parent 2bc4db1cab
commit 273fa75d55
6 changed files with 100 additions and 74 deletions

View file

@ -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)

View file

@ -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,7 +54,8 @@ 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",
@ -76,7 +79,8 @@ 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",
@ -100,7 +104,8 @@ 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",
@ -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()

View file

@ -1,23 +1,23 @@
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)
@ -30,9 +30,9 @@ class LoginTestCase(TestCase):
# #
# 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'

View file

@ -127,6 +127,7 @@ 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",

View file

@ -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)