Commit b69d4ce9 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

Fix pep8 errors

parent ca385c9a
......@@ -120,6 +120,7 @@ def get_user_mock(request, *args, **kwargs):
"name": "Firstname Lastname"}}
}
@mock.patch("astakosclient.AstakosClient", new=AstakosClientMock)
@mock.patch("snf_django.lib.astakos.get_user", new=get_user_mock)
class HelpdeskTests(TestCase):
......
......@@ -34,8 +34,6 @@
import os
from urlparse import urlparse
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from django.template import loader
......@@ -45,12 +43,9 @@ from django.utils import simplejson as json
from synnefo_branding.utils import render_to_string
from django.core.urlresolvers import reverse
from django.template import RequestContext
from synnefo_branding import settings as snf_settings
from synnefo.util.version import get_component_version
from synnefo.lib import join_urls
from synnefo import cyclades_settings
from synnefo.ui import settings as uisettings
SYNNEFO_JS_LIB_VERSION = get_component_version('app')
......@@ -101,7 +96,7 @@ SKIP_TIMEOUTS = getattr(settings, "UI_SKIP_TIMEOUTS", 1)
# Additional settings
VM_NAME_TEMPLATE = getattr(settings, "VM_CREATE_NAME_TPL", "My {0} server")
VM_HOSTNAME_FORMAT = getattr(settings, "UI_VM_HOSTNAME_FORMAT",
'snf-%(id)s.vm.synnefo.org')
'snf-%(id)s.vm.synnefo.org')
if isinstance(VM_HOSTNAME_FORMAT, basestring):
VM_HOSTNAME_FORMAT = VM_HOSTNAME_FORMAT % {'id': '{0}'}
......@@ -173,83 +168,81 @@ def template(name, request, context):
current_template = template_path + name + '.html'
t = loader.get_template(current_template)
media_context = {
'UI_MEDIA_URL': UI_MEDIA_URL,
'SYNNEFO_JS_URL': UI_SYNNEFO_JS_URL,
'SYNNEFO_JS_LIB_URL': UI_SYNNEFO_JS_LIB_URL,
'SYNNEFO_JS_WEB_URL': UI_SYNNEFO_JS_WEB_URL,
'SYNNEFO_IMAGES_URL': UI_SYNNEFO_IMAGES_URL,
'SYNNEFO_CSS_URL': UI_SYNNEFO_CSS_URL,
'SYNNEFO_JS_LIB_VERSION': SYNNEFO_JS_LIB_VERSION,
'DEBUG': settings.DEBUG
'UI_MEDIA_URL': UI_MEDIA_URL,
'SYNNEFO_JS_URL': UI_SYNNEFO_JS_URL,
'SYNNEFO_JS_LIB_URL': UI_SYNNEFO_JS_LIB_URL,
'SYNNEFO_JS_WEB_URL': UI_SYNNEFO_JS_WEB_URL,
'SYNNEFO_IMAGES_URL': UI_SYNNEFO_IMAGES_URL,
'SYNNEFO_CSS_URL': UI_SYNNEFO_CSS_URL,
'SYNNEFO_JS_LIB_VERSION': SYNNEFO_JS_LIB_VERSION,
'DEBUG': settings.DEBUG
}
context.update(media_context)
return HttpResponse(t.render(RequestContext(request, context)))
def home(request):
context = {'timeout': TIMEOUT,
'project': '+nefo',
'request': request,
'current_lang': get_language() or 'en',
'compute_api_url': json.dumps(uisettings.COMPUTE_URL),
'user_catalog_url': json.dumps(uisettings.USER_CATALOG_URL),
'feedback_post_url': json.dumps(uisettings.FEEDBACK_URL),
'accounts_api_url': json.dumps(uisettings.ACCOUNT_URL),
'logout_redirect': json.dumps(uisettings.LOGOUT_REDIRECT),
'login_redirect': json.dumps(uisettings.LOGIN_URL),
'glance_api_url': json.dumps(uisettings.GLANCE_URL),
'translate_uuids': json.dumps(True),
# update interval settings
'update_interval': UPDATE_INTERVAL,
'update_interval_increase': UPDATE_INTERVAL_INCREASE,
'update_interval_increase_after_calls':
UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT,
'update_interval_fast': UPDATE_INTERVAL_FAST,
'update_interval_max': UPDATE_INTERVAL_MAX,
'changes_since_alignment': CHANGES_SINCE_ALIGNMENT,
'image_icons': IMAGE_ICONS,
'auth_cookie_name': AUTH_COOKIE_NAME,
'auth_skip_redirects': json.dumps(AUTH_SKIP_REDIRECTS),
'suggested_flavors': json.dumps(SUGGESTED_FLAVORS),
'suggested_roles': json.dumps(SUGGESTED_ROLES),
'vm_image_common_metadata': json.dumps(VM_IMAGE_COMMON_METADATA),
'synnefo_version': SYNNEFO_JS_LIB_VERSION,
'delay_on_blur': json.dumps(DELAY_ON_BLUR),
'update_hidden_views': json.dumps(UPDATE_HIDDEN_VIEWS),
'handle_window_exceptions': json.dumps(HANDLE_WINDOW_EXCEPTIONS),
'skip_timeouts': json.dumps(SKIP_TIMEOUTS),
'vm_name_template': json.dumps(VM_NAME_TEMPLATE),
'flavors_disk_templates_info':
json.dumps(FLAVORS_DISK_TEMPLATES_INFO),
'support_ssh_os_list': json.dumps(SUPPORT_SSH_OS_LIST),
'unknown_os': json.dumps(UNKNOWN_OS),
'os_created_users': json.dumps(OS_CREATED_USERS),
'userdata_keys_limit': json.dumps(MAX_SSH_KEYS_PER_USER),
'use_glance': json.dumps(ENABLE_GLANCE),
'system_images_owners': json.dumps(SYSTEM_IMAGES_OWNERS),
'custom_image_help_url': CUSTOM_IMAGE_HELP_URL,
'image_deleted_title': json.dumps(IMAGE_DELETED_TITLE),
'image_deleted_size_title': json.dumps(IMAGE_DELETED_SIZE_TITLE),
'network_suggested_subnets': json.dumps(NETWORK_SUBNETS),
'network_available_types': json.dumps(NETWORK_TYPES),
'network_allow_duplicate_vm_nics':
json.dumps(NETWORK_DUPLICATE_NICS),
'network_strict_destroy': json.dumps(NETWORK_STRICT_DESTROY),
'network_allow_multiple_destroy':
json.dumps(NETWORK_ALLOW_MULTIPLE_DESTROY),
'automatic_network_range_format':
json.dumps(AUTOMATIC_NETWORK_RANGE_FORMAT),
'grouped_public_network_name':
json.dumps(GROUPED_PUBLIC_NETWORK_NAME),
'group_public_networks': json.dumps(GROUP_PUBLIC_NETWORKS),
'private_networks_nic_hotplug':
json.dumps(PRIVATE_NETWORKS_NIC_HOTPLUG),
'diagnostics_update_interval':
json.dumps(DIAGNOSTICS_UPDATE_INTERVAL),
'vm_hostname_format': json.dumps(VM_HOSTNAME_FORMAT)
}
context = {
'timeout': TIMEOUT,
'project': '+nefo',
'request': request,
'current_lang': get_language() or 'en',
'compute_api_url': json.dumps(uisettings.COMPUTE_URL),
'user_catalog_url': json.dumps(uisettings.USER_CATALOG_URL),
'feedback_post_url': json.dumps(uisettings.FEEDBACK_URL),
'accounts_api_url': json.dumps(uisettings.ACCOUNT_URL),
'logout_redirect': json.dumps(uisettings.LOGOUT_REDIRECT),
'login_redirect': json.dumps(uisettings.LOGIN_URL),
'glance_api_url': json.dumps(uisettings.GLANCE_URL),
'translate_uuids': json.dumps(True),
# update interval settings
'update_interval': UPDATE_INTERVAL,
'update_interval_increase': UPDATE_INTERVAL_INCREASE,
'update_interval_increase_after_calls':
UPDATE_INTERVAL_INCREASE_AFTER_CALLS_COUNT,
'update_interval_fast': UPDATE_INTERVAL_FAST,
'update_interval_max': UPDATE_INTERVAL_MAX,
'changes_since_alignment': CHANGES_SINCE_ALIGNMENT,
'image_icons': IMAGE_ICONS,
'auth_cookie_name': AUTH_COOKIE_NAME,
'auth_skip_redirects': json.dumps(AUTH_SKIP_REDIRECTS),
'suggested_flavors': json.dumps(SUGGESTED_FLAVORS),
'suggested_roles': json.dumps(SUGGESTED_ROLES),
'vm_image_common_metadata': json.dumps(VM_IMAGE_COMMON_METADATA),
'synnefo_version': SYNNEFO_JS_LIB_VERSION,
'delay_on_blur': json.dumps(DELAY_ON_BLUR),
'update_hidden_views': json.dumps(UPDATE_HIDDEN_VIEWS),
'handle_window_exceptions': json.dumps(HANDLE_WINDOW_EXCEPTIONS),
'skip_timeouts': json.dumps(SKIP_TIMEOUTS),
'vm_name_template': json.dumps(VM_NAME_TEMPLATE),
'flavors_disk_templates_info': json.dumps(FLAVORS_DISK_TEMPLATES_INFO),
'support_ssh_os_list': json.dumps(SUPPORT_SSH_OS_LIST),
'unknown_os': json.dumps(UNKNOWN_OS),
'os_created_users': json.dumps(OS_CREATED_USERS),
'userdata_keys_limit': json.dumps(MAX_SSH_KEYS_PER_USER),
'use_glance': json.dumps(ENABLE_GLANCE),
'system_images_owners': json.dumps(SYSTEM_IMAGES_OWNERS),
'custom_image_help_url': CUSTOM_IMAGE_HELP_URL,
'image_deleted_title': json.dumps(IMAGE_DELETED_TITLE),
'image_deleted_size_title': json.dumps(IMAGE_DELETED_SIZE_TITLE),
'network_suggested_subnets': json.dumps(NETWORK_SUBNETS),
'network_available_types': json.dumps(NETWORK_TYPES),
'network_allow_duplicate_vm_nics': json.dumps(NETWORK_DUPLICATE_NICS),
'network_strict_destroy': json.dumps(NETWORK_STRICT_DESTROY),
'network_allow_multiple_destroy':
json.dumps(NETWORK_ALLOW_MULTIPLE_DESTROY),
'automatic_network_range_format':
json.dumps(AUTOMATIC_NETWORK_RANGE_FORMAT),
'grouped_public_network_name': json.dumps(GROUPED_PUBLIC_NETWORK_NAME),
'group_public_networks': json.dumps(GROUP_PUBLIC_NETWORKS),
'private_networks_nic_hotplug':
json.dumps(PRIVATE_NETWORKS_NIC_HOTPLUG),
'diagnostics_update_interval': json.dumps(DIAGNOSTICS_UPDATE_INTERVAL),
'vm_hostname_format': json.dumps(VM_HOSTNAME_FORMAT)
}
return template('home', request, context)
def machines_console(request):
host, port, password = ('', '', '')
host = request.GET.get('host', '')
......@@ -259,7 +252,8 @@ def machines_console(request):
host_ip = request.GET.get('host_ip', '')
host_ip_v6 = request.GET.get('host_ip_v6', '')
context = {'host': host, 'port': port, 'password': password,
'machine': machine, 'host_ip': host_ip, 'host_ip_v6': host_ip_v6}
'machine': machine, 'host_ip': host_ip,
'host_ip_v6': host_ip_v6}
return template('machines_console', request, context)
......@@ -278,7 +272,8 @@ CONNECT_LINUX_WINDOWS_MESSAGE = \
<a target="_blank"
href="http://en.wikipedia.org/wiki/Remote_Desktop_Services">
Remote Desktop Service</a>.
To do so, open the following file with an appropriate remote desktop client.""")
To do so, open the following file with an appropriate \
remote desktop client.""")
CONNECT_LINUX_WINDOWS_SUBMESSAGE = \
_("""If you don't have a Remote Desktop client already installed,
we suggest the use of <a target="_blank"
......@@ -389,7 +384,7 @@ def machines_connect(request):
'ip_address': ip_address,
'hostname': hostname,
'user': username
}
}
rdp_context = {
'username': username,
......@@ -454,4 +449,3 @@ def machines_connect(request):
mimetype='application/json') # no windows, no rdp
return response
......@@ -51,7 +51,7 @@ def override_settings(settings, **kwargs):
>>> from synnefo.util.testing import override_settings
>>> from django.conf import settings
>>> with override_settings(settings, DEBUG=True):
>>> assert settings.DEBUG == True
... assert settings.DEBUG == True
The special arguemnt ``prefix`` can be set to prefix all setting keys with
the provided value.
......@@ -59,11 +59,11 @@ def override_settings(settings, **kwargs):
>>> from django.conf import settings
>>> from django.core import mail
>>> with override_settings(settings, CONTACT_EMAILS=['kpap@grnet.gr'],
>>> prefix='MYAPP_'):
>>> from django.core.mail import send_mail
>>> send_mail("hello", "I love you kpap", settings.DEFAULT_FROM_EMAIL,
>>> settings.MYAPP_CONTACT_EMAILS)
>>> assert 'kpap@grnet.gr' in mail.mailbox[0].recipients()
... prefix='MYAPP_'):
... from django.core.mail import send_mail
... send_mail("hello", "I love you kpap", settings.DEFAULT_FROM_EMAIL,
... settings.MYAPP_CONTACT_EMAILS)
... assert 'kpap@grnet.gr' in mail.mailbox[0].recipients()
If you plan to reuse it
......@@ -71,8 +71,8 @@ def override_settings(settings, **kwargs):
>>> from synnefo.util.testing import override_settings
>>> from django.conf import settings
>>> myapp_settings = functools.partial(override_settings, prefix='MYAPP_')
>>> with myapp_settings(CONTACT_EMAILS=['kpap@grnet.gr'])
>>> assert settings.MYAPP_CONTACT_EMAILS == ['kpap@grnet.gr']
>>> with myapp_settings(CONTACT_EMAILS=['kpap@grnet.gr']):
... assert settings.MYAPP_CONTACT_EMAILS == ['kpap@grnet.gr']
"""
......@@ -134,21 +134,21 @@ def astakos_user(user):
get_token.return_value = "DummyToken"
with patch('astakosclient.AstakosClient.authenticate') as m2:
m2.return_value = {"access": {
"token": {
"expires": "2013-06-19T15:23:59.975572+00:00",
"id": "DummyToken",
"tenant": {
"id": text.udec(user, 'utf8'),
"name": "Firstname Lastname"
}
},
"serviceCatalog": [],
"user": {
"roles_links": [],
"token": {
"expires": "2013-06-19T15:23:59.975572+00:00",
"id": "DummyToken",
"tenant": {
"id": text.udec(user, 'utf8'),
"roles": [{"id": 1, "name": "default"}],
"name": "Firstname Lastname"}}
}
"name": "Firstname Lastname"
}
},
"serviceCatalog": [],
"user": {
"roles_links": [],
"id": text.udec(user, 'utf8'),
"roles": [{"id": 1, "name": "default"}],
"name": "Firstname Lastname"}}
}
with patch('astakosclient.AstakosClient.get_quotas') as m3:
m3.return_value = {
......
......@@ -1897,6 +1897,7 @@ class ObjectPost(PithosAPITest):
HTTP_X_OBJECT_SHARING='write=%s' % (257*'a'))
self.assertEqual(r.status_code, 400)
class ObjectDelete(PithosAPITest):
def setUp(self):
PithosAPITest.setUp(self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment