Commit f32b5c83 authored by Dimitris Moraitis's avatar Dimitris Moraitis
Browse files

pep8 compliance

parent 0abe2ed3
......@@ -26,4 +26,3 @@ class TokenAuthentication(object):
def challenge(self):
return fault.unauthorized.response
......@@ -26,4 +26,4 @@ class ItemNotFound(Fault):
code = 404
class ServiceUnavailable(Fault):
code = 503
\ No newline at end of file
code = 503
This diff is collapsed.
This diff is collapsed.
......@@ -8,6 +8,7 @@ from django.conf.urls.defaults import url
_accept_re = re.compile(r'([^\s;,]+)(?:[^,]*?;\s*q=(\d*(?:\.\d+)?))?')
def parse_accept_header(value):
"""Parse an HTTP Accept header
......@@ -30,6 +31,7 @@ def parse_accept_header(value):
return result
def url_with_format(regex, *args, **kwargs):
"""
An extended url() that adds an .json/.xml suffix to the end to avoid DRY
......
#!/usr/bin/python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
......
......@@ -16,14 +16,17 @@ MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
# 'postgresql_psycopg2', 'postgresql','mysql', 'sqlite3' or 'oracle'
'ENGINE': 'sqlite3',
# ATTENTION: This *must* be the absolute path if using sqlite3.
# See: http://docs.djangoproject.com/en/dev/ref/settings/#name
'NAME': PROJECT_PATH + 'database.sqlite',
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
# Set to empty string for localhost. Not used with sqlite3.
'HOST': '',
# Set to empty string for default. Not used with sqlite3.
'PORT': '',
# Uncomment for MySQL
#'OPTIONS': {
# 'init_command': 'SET storage_engine=INNODB',
......@@ -101,7 +104,8 @@ MIDDLEWARE_CLASSES = (
ROOT_URLCONF = 'synnefo.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Put strings here, like "/home/html/django_templates"
# or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
......@@ -121,20 +125,25 @@ INSTALLED_APPS = (
'synnefo.ganeti',
)
GANETI_CLUSTER_INFO = ("62.217.120.78",5080,"synnefo","ocean!")
BACKEND_PREFIX_ID = "snf-" #ganeti needs each machine to have a unique name
GANETI_CLUSTER_INFO = ("62.217.120.78", 5080, "synnefo", "ocean!")
# ganeti requires each machine to have a unique name
BACKEND_PREFIX_ID = "snf-"
LANGUAGES = (
('el', u'Ελληνικά'),
('en', 'English'),
)
AUTH_PROFILE_MODULE = 'synnefo.OceanUser'
#needed for django. this is the class that implements the User system. We use this to allow users to add stuff for themselves (about, image etc)
# needed for django. this is the class that implements the User system.
# We use this to allow users to add stuff for themselves (about, image etc)
#http://docs.djangoproject.com/en/dev/topics/auth/#auth-profiles
AUTH_PROFILE_MODULE = 'synnefo.OceanUser'
# after this time passes and the client gets no response,
# it raises an alert that there are network problems
TIMEOUT = 10 * 1000
TIMEOUT = 10*1000
#after this time passes and the client gets no response, it raises an alert that there are network problems
POLL_LIMIT = 3600
#maximum number of seconds, needed for server and images polling
......
from django import http
from django.conf import settings
from django.utils.translation import check_for_language, activate, to_locale, get_language
from django.utils.translation import activate, to_locale
from django.utils.translation import check_for_language, get_language
def set_language(request):
"""
......
......@@ -3,6 +3,7 @@ from selenium import selenium
from multiprocessing import Process
from time import sleep
class FunctionalCase(TestCase):
"""
Functional tests for synnefo.ui using Selenium
......@@ -16,13 +17,12 @@ class FunctionalCase(TestCase):
"http://localhost:8000/")
self.selenium.start()
def tearDown(self):
"""Kill processes"""
TestCase.tearDown(self)
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
def test_wizard(self):
sel = self.selenium
sel.open("/")
......@@ -35,12 +35,18 @@ class FunctionalCase(TestCase):
sleep(2)
sel.click("medium")
sleep(2)
try: self.assertEqual("2048", sel.get_value("ram-indicator"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.assertEqual("2", sel.get_value("cpu-indicator"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.assertEqual("40", sel.get_value("storage-indicator"))
except AssertionError, e: self.verificationErrors.append(str(e))
try:
self.assertEqual("2048", sel.get_value("ram-indicator"))
except AssertionError, e:
self.verificationErrors.append(str(e))
try:
self.assertEqual("2", sel.get_value("cpu-indicator"))
except AssertionError, e:
self.verificationErrors.append(str(e))
try:
self.assertEqual("40", sel.get_value("storage-indicator"))
except AssertionError, e:
self.verificationErrors.append(str(e))
sleep(2)
sel.click("//div[@id='wizard']/div/div[2]/button[2]")
sleep(2)
......@@ -49,11 +55,13 @@ class FunctionalCase(TestCase):
self.assertEqual("40", sel.get_text("machine_storage-label"))
sel.click("start")
sleep(2)
try: self.failUnless(sel.is_text_present("Success"))
except AssertionError, e: self.verificationErrors.append(str(e))
try:
self.failUnless(sel.is_text_present("Success"))
except AssertionError, e:
self.verificationErrors.append(str(e))
#self.assertEqual("Success!", sel.get_text("//div[@id='error-success']/h3"))
#self.assertEqual("Success!",
# sel.get_text("//div[@id='error-success']/h3"))
#sel.click("//div[@id='error-success']/a")
#try: self.failUnless(sel.is_text_present("My Debian Unstable server"))
#except AssertionError, e: self.verificationErrors.append(str(e))
from django.conf.urls.defaults import *
import os
urlpatterns = patterns('',
(r'^$', 'synnefo.ui.views.home'),
(r'^machines$', 'synnefo.ui.views.machines'),
(r'^machines/standard$', 'synnefo.ui.views.machines_standard'),
(r'^machines/standard$', 'synnefo.ui.views.machines_standard'),
(r'^machines/list$', 'synnefo.ui.views.machines_list'),
(r'^disks$', 'synnefo.ui.views.disks'),
(r'^images$', 'synnefo.ui.views.images'),
......@@ -12,6 +13,6 @@ urlpatterns = patterns('',
(r'^files$', 'synnefo.ui.views.files'),
(r'^desktops$', 'synnefo.ui.views.desktops'),
(r'^apps$', 'synnefo.ui.views.apps'),
(r'^static/(.*)$', 'django.views.static.serve', {'document_root': os.path.join(os.path.dirname(__file__),'static')}),
(r'^static/(.*)$', 'django.views.static.serve',
{'document_root': os.path.join(os.path.dirname(__file__), 'static')}),
)
......@@ -7,48 +7,62 @@ from django.utils.translation import get_language
TIMEOUT = settings.TIMEOUT
def template(name, context):
template_path = os.path.join(os.path.dirname(__file__), "templates/")
template_path = os.path.join(os.path.dirname(__file__), "templates/")
current_template = template_path + name + '.html'
t = loader.get_template(current_template)
return HttpResponse(t.render(Context(context)))
def home(request):
context = { 'timeout': TIMEOUT, 'project' : '+nefo', 'request': request, 'current_lang' : get_language() or 'en' }
context = {'timeout': TIMEOUT,
'project': '+nefo',
'request': request,
'current_lang': get_language() or 'en'}
return template('home', context)
def machines(request):
context = {}
return template('machines', context)
def machines_standard(request):
context = {}
return template('standard', context)
def machines_list(request):
context = {}
return template('list', context)
def images(request):
def images(request):
context = {}
return template('images', context)
def disks(request):
context = {}
return template('disks', context)
def networks(request):
context = {}
return template('networks', context)
def files(request):
context = {}
return template('files', context)
def desktops(request):
context = {}
return template('desktops', context)
def apps(request):
context = {}
return template('apps', context)
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