commit e6f3e652d2aafca18457c6dcf2fa4d5949f07630
Author: Kostas Papadimitriou <kpap@grnet.gr>
Date:   Mon Nov 26 14:11:13 2012 +0200

    snf-ize quotaholder-app package

diff --git a/.gitignore b/.gitignore
index 27ae054..ed6e6c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,6 @@ _build
 */synnefo/versions/*.py
 !*/synnefo/versions/__init__.py
 snf-tools/synnefo_tools/version.py
-
+snf-quotaholder-app/quotaholder_django/version.py
 *.iml
 *.graffle
diff --git a/snf-quotaholder-app/Changelog b/snf-quotaholder-app/Changelog
new file mode 100644
index 0000000..e69de29
diff --git a/snf-quotaholder-app/MANIFEST.in b/snf-quotaholder-app/MANIFEST.in
new file mode 100644
index 0000000..1cd0270
--- /dev/null
+++ b/snf-quotaholder-app/MANIFEST.in
@@ -0,0 +1,3 @@
+include README Changelog
+include distribute_setup.py
+recursive-include quotaholder_django/quotaholder_app/fixtures *.json
diff --git a/snf-quotaholder-app/README b/snf-quotaholder-app/README
new file mode 100644
index 0000000..e69de29
diff --git a/snf-quotaholder-app/distribute_setup.py b/snf-quotaholder-app/distribute_setup.py
new file mode 100644
index 0000000..10d6684
--- /dev/null
+++ b/snf-quotaholder-app/distribute_setup.py
@@ -0,0 +1,485 @@
+#!python
+"""Bootstrap distribute installation
+
+If you want to use setuptools in your package's setup.py, just include this
+file in the same directory with it, and add this to the top of your setup.py::
+
+    from distribute_setup import use_setuptools
+    use_setuptools()
+
+If you want to require a specific version of setuptools, set a download
+mirror, or use an alternate download directory, you can do so by supplying
+the appropriate options to ``use_setuptools()``.
+
+This file can also be run as a script to install or upgrade setuptools.
+"""
+import os
+import sys
+import time
+import fnmatch
+import tempfile
+import tarfile
+from distutils import log
+
+try:
+    from site import USER_SITE
+except ImportError:
+    USER_SITE = None
+
+try:
+    import subprocess
+
+    def _python_cmd(*args):
+        args = (sys.executable,) + args
+        return subprocess.call(args) == 0
+
+except ImportError:
+    # will be used for python 2.3
+    def _python_cmd(*args):
+        args = (sys.executable,) + args
+        # quoting arguments if windows
+        if sys.platform == 'win32':
+            def quote(arg):
+                if ' ' in arg:
+                    return '"%s"' % arg
+                return arg
+            args = [quote(arg) for arg in args]
+        return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
+
+DEFAULT_VERSION = "0.6.10"
+DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
+SETUPTOOLS_FAKED_VERSION = "0.6c11"
+
+SETUPTOOLS_PKG_INFO = """\
+Metadata-Version: 1.0
+Name: setuptools
+Version: %s
+Summary: xxxx
+Home-page: xxx
+Author: xxx
+Author-email: xxx
+License: xxx
+Description: xxx
+""" % SETUPTOOLS_FAKED_VERSION
+
+
+def _install(tarball):
+    # extracting the tarball
+    tmpdir = tempfile.mkdtemp()
+    log.warn('Extracting in %s', tmpdir)
+    old_wd = os.getcwd()
+    try:
+        os.chdir(tmpdir)
+        tar = tarfile.open(tarball)
+        _extractall(tar)
+        tar.close()
+
+        # going in the directory
+        subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
+        os.chdir(subdir)
+        log.warn('Now working in %s', subdir)
+
+        # installing
+        log.warn('Installing Distribute')
+        if not _python_cmd('setup.py', 'install'):
+            log.warn('Something went wrong during the installation.')
+            log.warn('See the error message above.')
+    finally:
+        os.chdir(old_wd)
+
+
+def _build_egg(egg, tarball, to_dir):
+    # extracting the tarball
+    tmpdir = tempfile.mkdtemp()
+    log.warn('Extracting in %s', tmpdir)
+    old_wd = os.getcwd()
+    try:
+        os.chdir(tmpdir)
+        tar = tarfile.open(tarball)
+        _extractall(tar)
+        tar.close()
+
+        # going in the directory
+        subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
+        os.chdir(subdir)
+        log.warn('Now working in %s', subdir)
+
+        # building an egg
+        log.warn('Building a Distribute egg in %s', to_dir)
+        _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
+
+    finally:
+        os.chdir(old_wd)
+    # returning the result
+    log.warn(egg)
+    if not os.path.exists(egg):
+        raise IOError('Could not build the egg.')
+
+
+def _do_download(version, download_base, to_dir, download_delay):
+    egg = os.path.join(to_dir, 'distribute-%s-py%d.%d.egg'
+                       % (version, sys.version_info[0], sys.version_info[1]))
+    if not os.path.exists(egg):
+        tarball = download_setuptools(version, download_base,
+                                      to_dir, download_delay)
+        _build_egg(egg, tarball, to_dir)
+    sys.path.insert(0, egg)
+    import setuptools
+    setuptools.bootstrap_install_from = egg
+
+
+def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
+                   to_dir=os.curdir, download_delay=15, no_fake=True):
+    # making sure we use the absolute path
+    to_dir = os.path.abspath(to_dir)
+    was_imported = 'pkg_resources' in sys.modules or \
+        'setuptools' in sys.modules
+    try:
+        try:
+            import pkg_resources
+            if not hasattr(pkg_resources, '_distribute'):
+                if not no_fake:
+                    _fake_setuptools()
+                raise ImportError
+        except ImportError:
+            return _do_download(version, download_base, to_dir, download_delay)
+        try:
+            pkg_resources.require("distribute>="+version)
+            return
+        except pkg_resources.VersionConflict:
+            e = sys.exc_info()[1]
+            if was_imported:
+                sys.stderr.write(
+                "The required version of distribute (>=%s) is not available,\n"
+                "and can't be installed while this script is running. Please\n"
+                "install a more recent version first, using\n"
+                "'easy_install -U distribute'."
+                "\n\n(Currently using %r)\n" % (version, e.args[0]))
+                sys.exit(2)
+            else:
+                del pkg_resources, sys.modules['pkg_resources']    # reload ok
+                return _do_download(version, download_base, to_dir,
+                                    download_delay)
+        except pkg_resources.DistributionNotFound:
+            return _do_download(version, download_base, to_dir,
+                                download_delay)
+    finally:
+        if not no_fake:
+            _create_fake_setuptools_pkg_info(to_dir)
+
+def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
+                        to_dir=os.curdir, delay=15):
+    """Download distribute from a specified location and return its filename
+
+    `version` should be a valid distribute version number that is available
+    as an egg for download under the `download_base` URL (which should end
+    with a '/'). `to_dir` is the directory where the egg will be downloaded.
+    `delay` is the number of seconds to pause before an actual download
+    attempt.
+    """
+    # making sure we use the absolute path
+    to_dir = os.path.abspath(to_dir)
+    try:
+        from urllib.request import urlopen
+    except ImportError:
+        from urllib2 import urlopen
+    tgz_name = "distribute-%s.tar.gz" % version
+    url = download_base + tgz_name
+    saveto = os.path.join(to_dir, tgz_name)
+    src = dst = None
+    if not os.path.exists(saveto):  # Avoid repeated downloads
+        try:
+            log.warn("Downloading %s", url)
+            src = urlopen(url)
+            # Read/write all in one block, so we don't create a corrupt file
+            # if the download is interrupted.
+            data = src.read()
+            dst = open(saveto, "wb")
+            dst.write(data)
+        finally:
+            if src:
+                src.close()
+            if dst:
+                dst.close()
+    return os.path.realpath(saveto)
+
+def _no_sandbox(function):
+    def __no_sandbox(*args, **kw):
+        try:
+            from setuptools.sandbox import DirectorySandbox
+            if not hasattr(DirectorySandbox, '_old'):
+                def violation(*args):
+                    pass
+                DirectorySandbox._old = DirectorySandbox._violation
+                DirectorySandbox._violation = violation
+                patched = True
+            else:
+                patched = False
+        except ImportError:
+            patched = False
+
+        try:
+            return function(*args, **kw)
+        finally:
+            if patched:
+                DirectorySandbox._violation = DirectorySandbox._old
+                del DirectorySandbox._old
+
+    return __no_sandbox
+
+def _patch_file(path, content):
+    """Will backup the file then patch it"""
+    existing_content = open(path).read()
+    if existing_content == content:
+        # already patched
+        log.warn('Already patched.')
+        return False
+    log.warn('Patching...')
+    _rename_path(path)
+    f = open(path, 'w')
+    try:
+        f.write(content)
+    finally:
+        f.close()
+    return True
+
+_patch_file = _no_sandbox(_patch_file)
+
+def _same_content(path, content):
+    return open(path).read() == content
+
+def _rename_path(path):
+    new_name = path + '.OLD.%s' % time.time()
+    log.warn('Renaming %s into %s', path, new_name)
+    os.rename(path, new_name)
+    return new_name
+
+def _remove_flat_installation(placeholder):
+    if not os.path.isdir(placeholder):
+        log.warn('Unkown installation at %s', placeholder)
+        return False
+    found = False
+    for file in os.listdir(placeholder):
+        if fnmatch.fnmatch(file, 'setuptools*.egg-info'):
+            found = True
+            break
+    if not found:
+        log.warn('Could not locate setuptools*.egg-info')
+        return
+
+    log.warn('Removing elements out of the way...')
+    pkg_info = os.path.join(placeholder, file)
+    if os.path.isdir(pkg_info):
+        patched = _patch_egg_dir(pkg_info)
+    else:
+        patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO)
+
+    if not patched:
+        log.warn('%s already patched.', pkg_info)
+        return False
+    # now let's move the files out of the way
+    for element in ('setuptools', 'pkg_resources.py', 'site.py'):
+        element = os.path.join(placeholder, element)
+        if os.path.exists(element):
+            _rename_path(element)
+        else:
+            log.warn('Could not find the %s element of the '
+                     'Setuptools distribution', element)
+    return True
+
+_remove_flat_installation = _no_sandbox(_remove_flat_installation)
+
+def _after_install(dist):
+    log.warn('After install bootstrap.')
+    placeholder = dist.get_command_obj('install').install_purelib
+    _create_fake_setuptools_pkg_info(placeholder)
+
+def _create_fake_setuptools_pkg_info(placeholder):
+    if not placeholder or not os.path.exists(placeholder):
+        log.warn('Could not find the install location')
+        return
+    pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
+    setuptools_file = 'setuptools-%s-py%s.egg-info' % \
+            (SETUPTOOLS_FAKED_VERSION, pyver)
+    pkg_info = os.path.join(placeholder, setuptools_file)
+    if os.path.exists(pkg_info):
+        log.warn('%s already exists', pkg_info)
+        return
+
+    log.warn('Creating %s', pkg_info)
+    f = open(pkg_info, 'w')
+    try:
+        f.write(SETUPTOOLS_PKG_INFO)
+    finally:
+        f.close()
+
+    pth_file = os.path.join(placeholder, 'setuptools.pth')
+    log.warn('Creating %s', pth_file)
+    f = open(pth_file, 'w')
+    try:
+        f.write(os.path.join(os.curdir, setuptools_file))
+    finally:
+        f.close()
+
+_create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info)
+
+def _patch_egg_dir(path):
+    # let's check if it's already patched
+    pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
+    if os.path.exists(pkg_info):
+        if _same_content(pkg_info, SETUPTOOLS_PKG_INFO):
+            log.warn('%s already patched.', pkg_info)
+            return False
+    _rename_path(path)
+    os.mkdir(path)
+    os.mkdir(os.path.join(path, 'EGG-INFO'))
+    pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
+    f = open(pkg_info, 'w')
+    try:
+        f.write(SETUPTOOLS_PKG_INFO)
+    finally:
+        f.close()
+    return True
+
+_patch_egg_dir = _no_sandbox(_patch_egg_dir)
+
+def _before_install():
+    log.warn('Before install bootstrap.')
+    _fake_setuptools()
+
+
+def _under_prefix(location):
+    if 'install' not in sys.argv:
+        return True
+    args = sys.argv[sys.argv.index('install')+1:]
+    for index, arg in enumerate(args):
+        for option in ('--root', '--prefix'):
+            if arg.startswith('%s=' % option):
+                top_dir = arg.split('root=')[-1]
+                return location.startswith(top_dir)
+            elif arg == option:
+                if len(args) > index:
+                    top_dir = args[index+1]
+                    return location.startswith(top_dir)
+        if arg == '--user' and USER_SITE is not None:
+            return location.startswith(USER_SITE)
+    return True
+
+
+def _fake_setuptools():
+    log.warn('Scanning installed packages')
+    try:
+        import pkg_resources
+    except ImportError:
+        # we're cool
+        log.warn('Setuptools or Distribute does not seem to be installed.')
+        return
+    ws = pkg_resources.working_set
+    try:
+        setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools',
+                                  replacement=False))
+    except TypeError:
+        # old distribute API
+        setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools'))
+
+    if setuptools_dist is None:
+        log.warn('No setuptools distribution found')
+        return
+    # detecting if it was already faked
+    setuptools_location = setuptools_dist.location
+    log.warn('Setuptools installation detected at %s', setuptools_location)
+
+    # if --root or --preix was provided, and if
+    # setuptools is not located in them, we don't patch it
+    if not _under_prefix(setuptools_location):
+        log.warn('Not patching, --root or --prefix is installing Distribute'
+                 ' in another location')
+        return
+
+    # let's see if its an egg
+    if not setuptools_location.endswith('.egg'):
+        log.warn('Non-egg installation')
+        res = _remove_flat_installation(setuptools_location)
+        if not res:
+            return
+    else:
+        log.warn('Egg installation')
+        pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO')
+        if (os.path.exists(pkg_info) and
+            _same_content(pkg_info, SETUPTOOLS_PKG_INFO)):
+            log.warn('Already patched.')
+            return
+        log.warn('Patching...')
+        # let's create a fake egg replacing setuptools one
+        res = _patch_egg_dir(setuptools_location)
+        if not res:
+            return
+    log.warn('Patched done.')
+    _relaunch()
+
+
+def _relaunch():
+    log.warn('Relaunching...')
+    # we have to relaunch the process
+    # pip marker to avoid a relaunch bug
+    if sys.argv[:3] == ['-c', 'install', '--single-version-externally-managed']:
+        sys.argv[0] = 'setup.py'
+    args = [sys.executable] + sys.argv
+    sys.exit(subprocess.call(args))
+
+
+def _extractall(self, path=".", members=None):
+    """Extract all members from the archive to the current working
+       directory and set owner, modification time and permissions on
+       directories afterwards. `path' specifies a different directory
+       to extract to. `members' is optional and must be a subset of the
+       list returned by getmembers().
+    """
+    import copy
+    import operator
+    from tarfile import ExtractError
+    directories = []
+
+    if members is None:
+        members = self
+
+    for tarinfo in members:
+        if tarinfo.isdir():
+            # Extract directories with a safe mode.
+            directories.append(tarinfo)
+            tarinfo = copy.copy(tarinfo)
+            tarinfo.mode = 448 # decimal for oct 0700
+        self.extract(tarinfo, path)
+
+    # Reverse sort directories.
+    if sys.version_info < (2, 4):
+        def sorter(dir1, dir2):
+            return cmp(dir1.name, dir2.name)
+        directories.sort(sorter)
+        directories.reverse()
+    else:
+        directories.sort(key=operator.attrgetter('name'), reverse=True)
+
+    # Set correct owner, mtime and filemode on directories.
+    for tarinfo in directories:
+        dirpath = os.path.join(path, tarinfo.name)
+        try:
+            self.chown(tarinfo, dirpath)
+            self.utime(tarinfo, dirpath)
+            self.chmod(tarinfo, dirpath)
+        except ExtractError:
+            e = sys.exc_info()[1]
+            if self.errorlevel > 1:
+                raise
+            else:
+                self._dbg(1, "tarfile: %s" % e)
+
+
+def main(argv, version=DEFAULT_VERSION):
+    """Install or upgrade setuptools and EasyInstall"""
+    tarball = download_setuptools()
+    _install(tarball)
+
+
+if __name__ == '__main__':
+    main(sys.argv[1:])
diff --git a/snf-quotaholder-app/quotaholder_django/synnefo_settings.py b/snf-quotaholder-app/quotaholder_django/synnefo_settings.py
new file mode 100644
index 0000000..9fd662e
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/synnefo_settings.py
@@ -0,0 +1,34 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+apps = ['south', 'quotaholder_django']
diff --git a/snf-quotaholder-app/quotaholder_django/test/__init__.py b/snf-quotaholder-app/quotaholder_django/test/__init__.py
new file mode 100644
index 0000000..3738668
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/__init__.py
@@ -0,0 +1,34 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+# placeholder
diff --git a/snf-quotaholder-app/quotaholder_django/test/__main__.py b/snf-quotaholder-app/quotaholder_django/test/__main__.py
new file mode 100644
index 0000000..21fee5c
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/__main__.py
@@ -0,0 +1,62 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+from sys import argv,executable
+from os.path import dirname
+from config import run_test_cases
+from config import printf
+from limits import LimitsTest
+from createrelease import CreateReleaseListAPITest
+
+HERE = dirname(__file__)
+
+# Enumerate all test cases to run.
+# In the command line use
+#   $ python test
+# to run them all
+
+all_cases = [
+    CreateReleaseListAPITest,
+    LimitsTest
+]
+
+printf("=======================================================")
+printf("Using {0} {1}", executable, ' '.join(argv))
+printf("Running tests from {0}", HERE)
+printf("=======================================================")
+printf("All tests are:")
+for test_case in all_cases:
+    printf("  {0}", test_case.__name__)
+run_test_cases(all_cases)
+printf("=======================================================")
+printf("")
diff --git a/snf-quotaholder-app/quotaholder_django/test/config.py b/snf-quotaholder-app/quotaholder_django/test/config.py
new file mode 100644
index 0000000..2e75a38
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/config.py
@@ -0,0 +1,154 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+### IMPORTS ###
+import sys
+import os
+import subprocess
+import time
+from socket import socket, AF_INET, SOCK_STREAM, IPPROTO_TCP, error as socket_error
+from errno import ECONNREFUSED
+from os.path import dirname
+
+# The following import is copied from snf-tools/syneffo_tools/burnin.py
+# Thank you John Giannelos <johngian@grnet.gr>
+# Use backported unittest functionality if Python < 2.7
+try:
+    import unittest2 as unittest
+except ImportError:
+    if sys.version_info < (2, 7):
+        raise Exception("The unittest2 package is required for Python < 2.7")
+    import unittest
+
+from kamaki.clients.quotaholder import QuotaholderClient
+from synnefo.lib.quotaholder.api import (InvalidKeyError, NoEntityError,
+                                         NoQuantityError, NoCapacityError,
+                                         ExportLimitError, ImportLimitError)
+
+import random 
+
+def printf(fmt, *args):
+    print(fmt.format(*args))
+
+def environ_get(key, default_value = ''):
+    if os.environ.has_key(key):
+        return os.environ.get(key)
+    else:
+        return default_value
+
+# Use environ vars [TEST_]QH_{HOST, PORT}
+QH_HOST = environ_get("TEST_QH_HOST", environ_get("QH_HOST", "127.0.0.1"))
+QH_PORT = environ_get("TEST_QH_PORT", environ_get("QH_PORT", "8008"))
+
+assert QH_HOST != None
+assert QH_PORT != None
+
+printf("Will connect to QH_HOST = {0}", QH_HOST)
+printf("            and QH_PORT = {0}", QH_PORT)
+
+QH_SERVER = '{0}:{1}'.format(QH_HOST, QH_PORT)
+QH_URL = "http://{0}/api/quotaholder/v".format(QH_SERVER)
+
+### DEFS ###
+def new_quota_holder_client():
+    """
+    Create a new quota holder api client
+    """
+    return QuotaholderClient(QH_URL)
+
+def run_test_case(test_case):
+    """
+    Runs the test_case and returns the result
+    """
+    # Again from snf-tools/synnefo_tools/burnin.py
+    # Thank you John Giannelos <johngian@grnet.gr>
+    printf("Running {0}", test_case)
+    import sys
+    suite = unittest.TestLoader().loadTestsFromTestCase(test_case)
+    runner = unittest.TextTestRunner(stream=sys.stderr, verbosity=2,
+                                     failfast=True, buffer=False)
+    return runner.run(suite)
+
+def run_test_cases(test_cases):
+    for test_case in test_cases:
+        run_test_case(test_case)
+
+def rand_string():
+   alphabet = 'abcdefghijklmnopqrstuvwxyz'
+   min = 5
+   max = 15
+   string=''
+   for x in random.sample(alphabet,random.randint(min,max)):
+    string += x
+   return string
+
+HERE = dirname(__file__)
+
+def init_server():
+    p = subprocess.Popen(['setsid', HERE+'/qh_init', QH_SERVER])
+    s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
+    while True:
+        try:
+            s.connect((QH_HOST, int(QH_PORT)))
+            break
+        except socket_error, e:
+            if e.errno != ECONNREFUSED:
+                raise
+            time.sleep(0.1)
+    return p.pid
+
+### CLASSES ###
+class QHTestCase(unittest.TestCase):
+    @classmethod
+    def setUpClass(self):
+        self.server = init_server()
+        self.qh = new_quota_holder_client()
+#        self.qh.create_entity(create_entity=[("pgerakios", "system", "key1", "")])
+
+    def setUp(self):
+        print
+
+    @classmethod
+    def tearDownClass(self):
+        from signal import SIGTERM
+        os.kill(-self.server, SIGTERM)
+        os.remove('/tmp/qh_testdb')
+        del self.qh
+
+
+### VARS ###
+DefaultOrCustom = {
+    True: "default",
+    False: "custom"
+}
+
diff --git a/snf-quotaholder-app/quotaholder_django/test/createrelease.py b/snf-quotaholder-app/quotaholder_django/test/createrelease.py
new file mode 100644
index 0000000..4ba410a
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/createrelease.py
@@ -0,0 +1,190 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+from config import QHTestCase
+from config import run_test_case
+from config import rand_string
+from config import printf
+import os
+
+#def create_entity      OK
+#def set_entity_key     OK
+#def list_entities      OK
+#def get_entity         OK 
+#def get_limits         LOVERDOS
+#def set_limits         LOVERDOS
+#def release_entity     OK
+#def get_holding
+#def set_holding
+#def list_resources     
+#def get_quota
+#def set_quota
+#def issue_commission
+#def accept_commission
+#def reject_commission
+#def get_pending_commissions
+#def resolve_pending_commissions
+#def get_timeline
+
+class Context(object): 
+        entityName = rand_string()
+        entityKey = "key1" 
+        parentName = "pgerakios"
+        parentKey = "key1"
+
+class create_release(object):
+
+    def __init__(self, f):
+        """
+        If there are no decorator arguments, the function
+        to be decorated is passed to the constructor.
+        """
+        print "Inside __init__()"
+        self.f = f
+
+    def __call__(self, *args):
+        """
+        The __call__ method is not called until the
+        decorated function is called.
+        """
+        print "Inside __call__()"
+        self.f(*args)
+        print "After self.f(*args)"
+
+
+class CreateReleaseListAPITest(QHTestCase):
+
+    entityName = rand_string()
+    entityKey = "key1" 
+    parentName = "pgerakios"
+    parentKey = "key1"
+
+    def createEntity(self):
+        printf("Creating entity: {0}", self.entityName)
+        rejected = self.qh.create_entity(context={},
+                                        create_entity=[(self.entityName,
+                                                        self.parentName,
+                                                        self.entityKey,
+                                                        self.parentKey)])
+        self.assertEqual(rejected,[])
+
+    def releaseEntity(self):        
+        printf("Releasing entity: {0}", self.entityName)
+        rejected = self.qh.release_entity(context={},release_entity=[(self.entityName,
+                                                                      self.entityKey)])
+        self.assertEqual(rejected,[])
+
+    def checkEntityList(self,exists):
+        entityList = self.qh.list_entities(context={},entity=self.parentName,key=self.parentKey)
+        if(exists):
+            self.assertTrue(self.entityName in entityList)
+        else:
+            self.assertFalse(self.entityName in entityList)
+
+    def setNewEntityKey(self):
+         entityKey2 = rand_string()
+         rejected = self.qh.set_entity_key(context={},set_entity_key=[(self.entityName,
+                                                                       self.entityKey,
+                                                                       entityKey2)])
+         self.assertEqual(rejected,[])
+         self.entityKey = entityKey2
+           
+    def checkGetEntity(self,exists):
+        entityList = self.qh.get_entity(context={},get_entity=[(self.entityName,
+                                                                self.entityKey)])
+        if(exists):
+            self.assertEqual([(self.entityName,self.parentName)],entityList)
+        else:
+            self.assertEqual(entityList,[])
+
+    def listResources(self,expected):
+        resList = self.qh.list_resources(context={},entity=self.entityName,key=self.entityKey)
+        self.assertEqual(expected,resList)
+
+    def setQuota(self,r,q,c,i,e,f):
+        rejected = self.qh.set_quota(context={},set_quota=[(self.entityName,r,self.entityKey,q,c,i,e,f)])
+        self.assertEqual(rejected,[])
+        resList = self.qh.get_quota(context={},get_quota=[(self.entityName,r,self.entityKey)])
+        (e0,r1,q1,c1,i1,e1,t0,t1,t2,t3,f1),tail = resList[0],resList[1:]
+        self.assertEqual(tail,[])
+        self.assertEqual((self.entityName,r,q,c,i,e,f),
+                         (e0,r1,q1,c1,i1,e1,f1))
+
+        #    def issueCommission(self):
+        # self.qh.issue_commission
+    def setUp(self):
+        self.qh.create_entity(create_entity=[("pgerakios", "system", "key1", "")])
+        self.parentName = "pgerakios"
+        self.parentKey = "key1"
+
+
+
+    #BUG: max empty name <= 72 
+    def test_001(self):
+        self.createEntity()
+        self.releaseEntity()
+
+    # Test create, list and release
+    def test_002(self):
+        self.checkEntityList(False)
+        self.createEntity()
+        self.checkEntityList(True)
+        self.releaseEntity()
+        self.checkEntityList(False)
+
+
+    # Test create,set key and release
+    def test_003(self):
+        self.createEntity()
+        self.setNewEntityKey()
+        self.setNewEntityKey()
+        self.releaseEntity()
+
+    # test get_entity
+    def test_004(self):
+        self.checkGetEntity(False)
+        self.createEntity()
+        self.checkGetEntity(True)
+        self.releaseEntity()
+        self.checkGetEntity(False)
+
+    def test_005(self):
+        self.createEntity()
+        self.setQuota("res1",10,100,10,10,0)
+#        self.listResources([])
+        self.releaseEntity()
+
+if __name__ == "__main__":
+    import sys
+    printf("Using {0}", sys.executable)
+    run_test_case(CreateReleaseListAPITest)
diff --git a/snf-quotaholder-app/quotaholder_django/test/django.conf b/snf-quotaholder-app/quotaholder_django/test/django.conf
new file mode 100644
index 0000000..aad8b18
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/django.conf
@@ -0,0 +1,10 @@
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': '/tmp/qh_testdb',
+    }
+}
diff --git a/snf-quotaholder-app/quotaholder_django/test/limits.py b/snf-quotaholder-app/quotaholder_django/test/limits.py
new file mode 100644
index 0000000..4a808f2
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/limits.py
@@ -0,0 +1,138 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+from config import QHTestCase
+from config import run_test_case
+from config import printf
+from config import rand_string
+from random import randint
+
+from synnefo.lib.quotaholder.api import InvalidDataError
+
+class Data:
+    def __init__(self, parent, **kwd):
+        self.context  = kwd.get('context', parent.context)
+        self.policy   = kwd.get('policy', parent.policy)
+        self.capacity = kwd.get('capacity', parent.capacity)
+        self.quantity = kwd.get('quantity', parent.quantity)
+        self.import_limit = kwd.get('import_limit', parent.import_limit)
+        self.export_limit = kwd.get('export_limit', parent.export_limit)
+        # set_limits_has_rejected indicates whether the test expects a non-empty rejected list
+        # after calling set_limits
+        self.set_limits_has_rejected = kwd.get('set_limits_has_rejected', False)
+        # get_limits_expected_length indicates the exact length of the limits list
+        # returned by get_limits
+        self.get_limits_expected_length = kwd.get('get_limits_expected_length', 1)
+
+class LimitsTest(QHTestCase):
+    context = {}
+    policy = rand_string()
+    capacity1 = 0
+    capacity2 = 100
+    capacity = capacity1
+    quantity1 = capacity2
+    quantity2 = capacity1
+    quantity = quantity1
+    import_limit_empty = 0
+    import_limit_full_capacity = capacity
+    import_limit_half_capacity = capacity / 2
+    import_limit = import_limit_half_capacity
+    export_limit_empty = 0
+    export_limit_full_capacity = capacity
+    export_limit_half_capacity = capacity / 2
+    export_limit = export_limit_half_capacity
+
+    def helper_set_limits(self, **kwd):
+        """
+        Calls set_limits and returns the rejected list (from the original API).
+        """
+        data = Data(self, **kwd)
+        rejected = self.qh.set_limits(
+            context = data.context,
+            set_limits = [
+                (data.policy,
+                 data.quantity,
+                 data.capacity,
+                 data.import_limit,
+                 data.export_limit)
+            ]
+        )
+
+        if data.set_limits_has_rejected:
+            self.assertTrue(len(rejected) > 1)
+        else:
+            self.assertTrue(len(rejected) == 0)
+
+        return rejected
+
+    def helper_get_limits(self, **kwd):
+        """
+        Calls get_limits and returns the limits list (from the original API)..
+        """
+        data = Data(self, **kwd)
+        limits = self.qh.get_limits(
+            context = data.context,
+            get_limits = [data.policy]
+        )
+
+        self.assertEqual(len(limits), data.get_limits_expected_length)
+
+        return limits
+
+    def test_010_set_get(self):
+        """
+        quantity = 0, capacity = 100
+        """
+        self.helper_set_limits(quantity = 0, capacity = 100, should_have_rejected = False)
+        self.helper_get_limits(get_limits_expected_length = 1)
+
+    def test_011_set_get(self):
+        """
+        quantity = 100, capacity = 0
+        """
+        self.helper_set_limits(quantity = 100, capacity = 0, should_have_rejected = False)
+        self.helper_get_limits(get_limits_expected_length = 1)
+
+    def test_020_set_get_empty_policy_name(self):
+        """
+        Tests empty policy name
+        """
+        with self.assertRaises(InvalidDataError):
+            self.helper_set_limits(policy = '', set_limits_has_rejected = False)
+            self.helper_get_limits(policy = '', get_limits_expected_length = 1)
+
+
+if __name__ == "__main__":
+    import sys
+    printf("Using {0}", sys.executable)
+    run_test_case(LimitsTest)
diff --git a/snf-quotaholder-app/quotaholder_django/test/qh_init b/snf-quotaholder-app/quotaholder_django/test/qh_init
new file mode 100755
index 0000000..6fa4178
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/qh_init
@@ -0,0 +1,5 @@
+#!/bin/sh
+d=`dirname $0`
+export COMMISSIONING_CONF_DIR=$d
+quotaholder-manage syncdb
+quotaholder-manage runserver "$@" 2> $d/server_stderr &
diff --git a/snf-quotaholder-app/quotaholder_django/test/simpletests.py b/snf-quotaholder-app/quotaholder_django/test/simpletests.py
new file mode 100644
index 0000000..5cf68ce
--- /dev/null
+++ b/snf-quotaholder-app/quotaholder_django/test/simpletests.py
@@ -0,0 +1,55 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+
+from config import QHTestCase
+from config import run_test_case
+from config import rand_string
+from config import printf
+
+from synnefo.lib.commissioning import CallError
+
+class QHAPITest(QHTestCase):
+
+    def test_001(self):
+        r = self.qh.list_entities(entity='system', key='')
+        self.assertEqual(r, ['system'])
+
+    def test_002(self):
+        with self.assertRaises(CallError):
+            self.qh.list_entities(entity='systems', key='')
+
+
+if __name__ == "__main__":
+    import sys
+    printf("Using {0}", sys.executable)
+    run_test_case(QHAPITest)
diff --git a/snf-quotaholder-app/setup.py b/snf-quotaholder-app/setup.py
index e61aa34..52eeb3b 100644
--- a/snf-quotaholder-app/setup.py
+++ b/snf-quotaholder-app/setup.py
@@ -1,19 +1,101 @@
+# Copyright 2012 GRNET S.A. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+#   1. Redistributions of source code must retain the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer.
+#
+#   2. Redistributions in binary form must reproduce the above
+#      copyright notice, this list of conditions and the following
+#      disclaimer in the documentation and/or other materials
+#      provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and
+# documentation are those of the authors and should not be
+# interpreted as representing official policies, either expressed
+# or implied, of GRNET S.A.
+#
 
-from distutils.core import setup
+import distribute_setup
+distribute_setup.use_setuptools()
 
-setup   (
-    name            =   'quotaholder_django',
-    version         =   '0.5',
-    packages        =   [
-            'quotaholder_django',
-            'quotaholder_django.quotaholder_app',
-    ],
+import os
 
-    package_data    =   {
-            'quotaholder_django.quotaholder_app': ['fixtures/*.json']
-    },
+from distutils.util import convert_path
+from fnmatch import fnmatchcase
+from setuptools import setup, find_packages
+
+HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
+
+try:
+    # try to update the version file
+    from synnefo.util.version import update_version
+    update_version('quotaholder_django', 'version', HERE)
+except ImportError:
+    pass
+
+from quotaholder_django.version import __version__
+
+# Package info
+VERSION = __version__
+README = open(os.path.join(HERE, 'README')).read()
+CHANGES = open(os.path.join(HERE, 'Changelog')).read()
+SHORT_DESCRIPTION = 'snf-quotaholder django app'
+
+PACKAGES_ROOT = '.'
+PACKAGES = find_packages(PACKAGES_ROOT, exclude=('test',))
 
-    scripts         =   [
-            'quotaholder_django/quotaholder-manage',
-    ]
+# Package meta
+CLASSIFIERS = []
+INSTALL_REQUIRES = [
+    'Django >=1.2, <1.3',
+    'South>=0.7',
+    'snf-common',
+]
+
+setup(
+    name = 'snf-quotaholder-app',
+    version = VERSION,
+    license = 'BSD',
+    url = 'http://code.grnet.gr/',
+    description = SHORT_DESCRIPTION,
+    long_description=README + '\n\n' +  CHANGES,
+    classifiers = CLASSIFIERS,
+
+    author = 'Package author',
+    author_email = 'author@grnet.gr',
+    maintainer = 'Package maintainer',
+    maintainer_email = 'maintainer@grnet.gr',
+
+    packages = PACKAGES,
+    include_package_data = True,
+    package_data = {
+        'quotaholder_django.quotaholder_app': ['fixtures/*.json']
+    },
+    zip_safe = False,
+    install_requires = INSTALL_REQUIRES,
+    dependency_links = ['http://docs.dev.grnet.gr/pypi'],
+    entry_points = {
+     'synnefo': [
+         'web_apps = quotaholder_django.synnefo_settings:apps',
+         'urls = quotaholder_django.urls:urlpatterns',
+         ]
+      },
 )
+
diff --git a/snf-quotaholder-app/test/__init__.py b/snf-quotaholder-app/test/__init__.py
deleted file mode 100644
index 3738668..0000000
--- a/snf-quotaholder-app/test/__init__.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-# placeholder
diff --git a/snf-quotaholder-app/test/__main__.py b/snf-quotaholder-app/test/__main__.py
deleted file mode 100644
index 21fee5c..0000000
--- a/snf-quotaholder-app/test/__main__.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-from sys import argv,executable
-from os.path import dirname
-from config import run_test_cases
-from config import printf
-from limits import LimitsTest
-from createrelease import CreateReleaseListAPITest
-
-HERE = dirname(__file__)
-
-# Enumerate all test cases to run.
-# In the command line use
-#   $ python test
-# to run them all
-
-all_cases = [
-    CreateReleaseListAPITest,
-    LimitsTest
-]
-
-printf("=======================================================")
-printf("Using {0} {1}", executable, ' '.join(argv))
-printf("Running tests from {0}", HERE)
-printf("=======================================================")
-printf("All tests are:")
-for test_case in all_cases:
-    printf("  {0}", test_case.__name__)
-run_test_cases(all_cases)
-printf("=======================================================")
-printf("")
diff --git a/snf-quotaholder-app/test/config.py b/snf-quotaholder-app/test/config.py
deleted file mode 100644
index 2e75a38..0000000
--- a/snf-quotaholder-app/test/config.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# Copyright 2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-### IMPORTS ###
-import sys
-import os
-import subprocess
-import time
-from socket import socket, AF_INET, SOCK_STREAM, IPPROTO_TCP, error as socket_error
-from errno import ECONNREFUSED
-from os.path import dirname
-
-# The following import is copied from snf-tools/syneffo_tools/burnin.py
-# Thank you John Giannelos <johngian@grnet.gr>
-# Use backported unittest functionality if Python < 2.7
-try:
-    import unittest2 as unittest
-except ImportError:
-    if sys.version_info < (2, 7):
-        raise Exception("The unittest2 package is required for Python < 2.7")
-    import unittest
-
-from kamaki.clients.quotaholder import QuotaholderClient
-from synnefo.lib.quotaholder.api import (InvalidKeyError, NoEntityError,
-                                         NoQuantityError, NoCapacityError,
-                                         ExportLimitError, ImportLimitError)
-
-import random 
-
-def printf(fmt, *args):
-    print(fmt.format(*args))
-
-def environ_get(key, default_value = ''):
-    if os.environ.has_key(key):
-        return os.environ.get(key)
-    else:
-        return default_value
-
-# Use environ vars [TEST_]QH_{HOST, PORT}
-QH_HOST = environ_get("TEST_QH_HOST", environ_get("QH_HOST", "127.0.0.1"))
-QH_PORT = environ_get("TEST_QH_PORT", environ_get("QH_PORT", "8008"))
-
-assert QH_HOST != None
-assert QH_PORT != None
-
-printf("Will connect to QH_HOST = {0}", QH_HOST)
-printf("            and QH_PORT = {0}", QH_PORT)
-
-QH_SERVER = '{0}:{1}'.format(QH_HOST, QH_PORT)
-QH_URL = "http://{0}/api/quotaholder/v".format(QH_SERVER)
-
-### DEFS ###
-def new_quota_holder_client():
-    """
-    Create a new quota holder api client
-    """
-    return QuotaholderClient(QH_URL)
-
-def run_test_case(test_case):
-    """
-    Runs the test_case and returns the result
-    """
-    # Again from snf-tools/synnefo_tools/burnin.py
-    # Thank you John Giannelos <johngian@grnet.gr>
-    printf("Running {0}", test_case)
-    import sys
-    suite = unittest.TestLoader().loadTestsFromTestCase(test_case)
-    runner = unittest.TextTestRunner(stream=sys.stderr, verbosity=2,
-                                     failfast=True, buffer=False)
-    return runner.run(suite)
-
-def run_test_cases(test_cases):
-    for test_case in test_cases:
-        run_test_case(test_case)
-
-def rand_string():
-   alphabet = 'abcdefghijklmnopqrstuvwxyz'
-   min = 5
-   max = 15
-   string=''
-   for x in random.sample(alphabet,random.randint(min,max)):
-    string += x
-   return string
-
-HERE = dirname(__file__)
-
-def init_server():
-    p = subprocess.Popen(['setsid', HERE+'/qh_init', QH_SERVER])
-    s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
-    while True:
-        try:
-            s.connect((QH_HOST, int(QH_PORT)))
-            break
-        except socket_error, e:
-            if e.errno != ECONNREFUSED:
-                raise
-            time.sleep(0.1)
-    return p.pid
-
-### CLASSES ###
-class QHTestCase(unittest.TestCase):
-    @classmethod
-    def setUpClass(self):
-        self.server = init_server()
-        self.qh = new_quota_holder_client()
-#        self.qh.create_entity(create_entity=[("pgerakios", "system", "key1", "")])
-
-    def setUp(self):
-        print
-
-    @classmethod
-    def tearDownClass(self):
-        from signal import SIGTERM
-        os.kill(-self.server, SIGTERM)
-        os.remove('/tmp/qh_testdb')
-        del self.qh
-
-
-### VARS ###
-DefaultOrCustom = {
-    True: "default",
-    False: "custom"
-}
-
diff --git a/snf-quotaholder-app/test/createrelease.py b/snf-quotaholder-app/test/createrelease.py
deleted file mode 100644
index 4ba410a..0000000
--- a/snf-quotaholder-app/test/createrelease.py
+++ /dev/null
@@ -1,190 +0,0 @@
-# Copyright 2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-from config import QHTestCase
-from config import run_test_case
-from config import rand_string
-from config import printf
-import os
-
-#def create_entity      OK
-#def set_entity_key     OK
-#def list_entities      OK
-#def get_entity         OK 
-#def get_limits         LOVERDOS
-#def set_limits         LOVERDOS
-#def release_entity     OK
-#def get_holding
-#def set_holding
-#def list_resources     
-#def get_quota
-#def set_quota
-#def issue_commission
-#def accept_commission
-#def reject_commission
-#def get_pending_commissions
-#def resolve_pending_commissions
-#def get_timeline
-
-class Context(object): 
-        entityName = rand_string()
-        entityKey = "key1" 
-        parentName = "pgerakios"
-        parentKey = "key1"
-
-class create_release(object):
-
-    def __init__(self, f):
-        """
-        If there are no decorator arguments, the function
-        to be decorated is passed to the constructor.
-        """
-        print "Inside __init__()"
-        self.f = f
-
-    def __call__(self, *args):
-        """
-        The __call__ method is not called until the
-        decorated function is called.
-        """
-        print "Inside __call__()"
-        self.f(*args)
-        print "After self.f(*args)"
-
-
-class CreateReleaseListAPITest(QHTestCase):
-
-    entityName = rand_string()
-    entityKey = "key1" 
-    parentName = "pgerakios"
-    parentKey = "key1"
-
-    def createEntity(self):
-        printf("Creating entity: {0}", self.entityName)
-        rejected = self.qh.create_entity(context={},
-                                        create_entity=[(self.entityName,
-                                                        self.parentName,
-                                                        self.entityKey,
-                                                        self.parentKey)])
-        self.assertEqual(rejected,[])
-
-    def releaseEntity(self):        
-        printf("Releasing entity: {0}", self.entityName)
-        rejected = self.qh.release_entity(context={},release_entity=[(self.entityName,
-                                                                      self.entityKey)])
-        self.assertEqual(rejected,[])
-
-    def checkEntityList(self,exists):
-        entityList = self.qh.list_entities(context={},entity=self.parentName,key=self.parentKey)
-        if(exists):
-            self.assertTrue(self.entityName in entityList)
-        else:
-            self.assertFalse(self.entityName in entityList)
-
-    def setNewEntityKey(self):
-         entityKey2 = rand_string()
-         rejected = self.qh.set_entity_key(context={},set_entity_key=[(self.entityName,
-                                                                       self.entityKey,
-                                                                       entityKey2)])
-         self.assertEqual(rejected,[])
-         self.entityKey = entityKey2
-           
-    def checkGetEntity(self,exists):
-        entityList = self.qh.get_entity(context={},get_entity=[(self.entityName,
-                                                                self.entityKey)])
-        if(exists):
-            self.assertEqual([(self.entityName,self.parentName)],entityList)
-        else:
-            self.assertEqual(entityList,[])
-
-    def listResources(self,expected):
-        resList = self.qh.list_resources(context={},entity=self.entityName,key=self.entityKey)
-        self.assertEqual(expected,resList)
-
-    def setQuota(self,r,q,c,i,e,f):
-        rejected = self.qh.set_quota(context={},set_quota=[(self.entityName,r,self.entityKey,q,c,i,e,f)])
-        self.assertEqual(rejected,[])
-        resList = self.qh.get_quota(context={},get_quota=[(self.entityName,r,self.entityKey)])
-        (e0,r1,q1,c1,i1,e1,t0,t1,t2,t3,f1),tail = resList[0],resList[1:]
-        self.assertEqual(tail,[])
-        self.assertEqual((self.entityName,r,q,c,i,e,f),
-                         (e0,r1,q1,c1,i1,e1,f1))
-
-        #    def issueCommission(self):
-        # self.qh.issue_commission
-    def setUp(self):
-        self.qh.create_entity(create_entity=[("pgerakios", "system", "key1", "")])
-        self.parentName = "pgerakios"
-        self.parentKey = "key1"
-
-
-
-    #BUG: max empty name <= 72 
-    def test_001(self):
-        self.createEntity()
-        self.releaseEntity()
-
-    # Test create, list and release
-    def test_002(self):
-        self.checkEntityList(False)
-        self.createEntity()
-        self.checkEntityList(True)
-        self.releaseEntity()
-        self.checkEntityList(False)
-
-
-    # Test create,set key and release
-    def test_003(self):
-        self.createEntity()
-        self.setNewEntityKey()
-        self.setNewEntityKey()
-        self.releaseEntity()
-
-    # test get_entity
-    def test_004(self):
-        self.checkGetEntity(False)
-        self.createEntity()
-        self.checkGetEntity(True)
-        self.releaseEntity()
-        self.checkGetEntity(False)
-
-    def test_005(self):
-        self.createEntity()
-        self.setQuota("res1",10,100,10,10,0)
-#        self.listResources([])
-        self.releaseEntity()
-
-if __name__ == "__main__":
-    import sys
-    printf("Using {0}", sys.executable)
-    run_test_case(CreateReleaseListAPITest)
diff --git a/snf-quotaholder-app/test/django.conf b/snf-quotaholder-app/test/django.conf
deleted file mode 100644
index aad8b18..0000000
--- a/snf-quotaholder-app/test/django.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': '/tmp/qh_testdb',
-    }
-}
diff --git a/snf-quotaholder-app/test/limits.py b/snf-quotaholder-app/test/limits.py
deleted file mode 100644
index 4a808f2..0000000
--- a/snf-quotaholder-app/test/limits.py
+++ /dev/null
@@ -1,138 +0,0 @@
-# Copyright 2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-from config import QHTestCase
-from config import run_test_case
-from config import printf
-from config import rand_string
-from random import randint
-
-from synnefo.lib.quotaholder.api import InvalidDataError
-
-class Data:
-    def __init__(self, parent, **kwd):
-        self.context  = kwd.get('context', parent.context)
-        self.policy   = kwd.get('policy', parent.policy)
-        self.capacity = kwd.get('capacity', parent.capacity)
-        self.quantity = kwd.get('quantity', parent.quantity)
-        self.import_limit = kwd.get('import_limit', parent.import_limit)
-        self.export_limit = kwd.get('export_limit', parent.export_limit)
-        # set_limits_has_rejected indicates whether the test expects a non-empty rejected list
-        # after calling set_limits
-        self.set_limits_has_rejected = kwd.get('set_limits_has_rejected', False)
-        # get_limits_expected_length indicates the exact length of the limits list
-        # returned by get_limits
-        self.get_limits_expected_length = kwd.get('get_limits_expected_length', 1)
-
-class LimitsTest(QHTestCase):
-    context = {}
-    policy = rand_string()
-    capacity1 = 0
-    capacity2 = 100
-    capacity = capacity1
-    quantity1 = capacity2
-    quantity2 = capacity1
-    quantity = quantity1
-    import_limit_empty = 0
-    import_limit_full_capacity = capacity
-    import_limit_half_capacity = capacity / 2
-    import_limit = import_limit_half_capacity
-    export_limit_empty = 0
-    export_limit_full_capacity = capacity
-    export_limit_half_capacity = capacity / 2
-    export_limit = export_limit_half_capacity
-
-    def helper_set_limits(self, **kwd):
-        """
-        Calls set_limits and returns the rejected list (from the original API).
-        """
-        data = Data(self, **kwd)
-        rejected = self.qh.set_limits(
-            context = data.context,
-            set_limits = [
-                (data.policy,
-                 data.quantity,
-                 data.capacity,
-                 data.import_limit,
-                 data.export_limit)
-            ]
-        )
-
-        if data.set_limits_has_rejected:
-            self.assertTrue(len(rejected) > 1)
-        else:
-            self.assertTrue(len(rejected) == 0)
-
-        return rejected
-
-    def helper_get_limits(self, **kwd):
-        """
-        Calls get_limits and returns the limits list (from the original API)..
-        """
-        data = Data(self, **kwd)
-        limits = self.qh.get_limits(
-            context = data.context,
-            get_limits = [data.policy]
-        )
-
-        self.assertEqual(len(limits), data.get_limits_expected_length)
-
-        return limits
-
-    def test_010_set_get(self):
-        """
-        quantity = 0, capacity = 100
-        """
-        self.helper_set_limits(quantity = 0, capacity = 100, should_have_rejected = False)
-        self.helper_get_limits(get_limits_expected_length = 1)
-
-    def test_011_set_get(self):
-        """
-        quantity = 100, capacity = 0
-        """
-        self.helper_set_limits(quantity = 100, capacity = 0, should_have_rejected = False)
-        self.helper_get_limits(get_limits_expected_length = 1)
-
-    def test_020_set_get_empty_policy_name(self):
-        """
-        Tests empty policy name
-        """
-        with self.assertRaises(InvalidDataError):
-            self.helper_set_limits(policy = '', set_limits_has_rejected = False)
-            self.helper_get_limits(policy = '', get_limits_expected_length = 1)
-
-
-if __name__ == "__main__":
-    import sys
-    printf("Using {0}", sys.executable)
-    run_test_case(LimitsTest)
diff --git a/snf-quotaholder-app/test/qh_init b/snf-quotaholder-app/test/qh_init
deleted file mode 100755
index 6fa4178..0000000
--- a/snf-quotaholder-app/test/qh_init
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-d=`dirname $0`
-export COMMISSIONING_CONF_DIR=$d
-quotaholder-manage syncdb
-quotaholder-manage runserver "$@" 2> $d/server_stderr &
diff --git a/snf-quotaholder-app/test/simpletests.py b/snf-quotaholder-app/test/simpletests.py
deleted file mode 100644
index 5cf68ce..0000000
--- a/snf-quotaholder-app/test/simpletests.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 2012 GRNET S.A. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-#   1. Redistributions of source code must retain the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer.
-#
-#   2. Redistributions in binary form must reproduce the above
-#      copyright notice, this list of conditions and the following
-#      disclaimer in the documentation and/or other materials
-#      provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
-# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# The views and conclusions contained in the software and
-# documentation are those of the authors and should not be
-# interpreted as representing official policies, either expressed
-# or implied, of GRNET S.A.
-
-from config import QHTestCase
-from config import run_test_case
-from config import rand_string
-from config import printf
-
-from synnefo.lib.commissioning import CallError
-
-class QHAPITest(QHTestCase):
-
-    def test_001(self):
-        r = self.qh.list_entities(entity='system', key='')
-        self.assertEqual(r, ['system'])
-
-    def test_002(self):
-        with self.assertRaises(CallError):
-            self.qh.list_entities(entity='systems', key='')
-
-
-if __name__ == "__main__":
-    import sys
-    printf("Using {0}", sys.executable)
-    run_test_case(QHAPITest)
