Commit 76aed69f authored by Christos KK Loverdos's avatar Christos KK Loverdos

Organize testing infrastructure.

This is more of a personal (loverdos@gmail.com) setup for the moment
but all parts of it can be used in a generic way. I have named stuff
by prefixing them with 'kk', so that they do no clash with similar
test cases (pgerakios@grnet.gr). Having duplicate test cases is fine
right now, since everything is shaping up.

You can run all tests by using:

  $ python test

from the top folder.
parent 0501bd3e
# placeholder
\ No newline at end of file
import os
import sys
from kkquotaholderapi import KKQuotaHolderAPITest
# The following trick is from from snf-tools/synnefo_tools/burnin.py:
# 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
HERE = os.path.dirname(__file__)
# Enumerate all test cases to run.
# In the command line use
# $ python test
# to run them all
all_cases = [
KKQuotaHolderAPITest
]
if __name__ == "__main__":
print("Running tests from {0}".format(HERE))
print("All tests are: {0}".format(all_cases))
for test_case in all_cases:
print("Executing {0}".format(test_case))
# Again from snf-tools/synnefo_tools/burnin.py
# Thank you John Giannelos <johngian@grnet.gr>
suite = unittest.TestLoader().loadTestsFromTestCase(test_case)
runner = unittest.TextTestRunner(stream = sys.stderr, verbosity = 2, failfast = True, buffer = False)
result = runner.run(suite)
\ No newline at end of file
### IMPORTS ###
# 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:
import sys
if sys.version_info < (2, 7):
raise Exception("The unittest2 package is required for Python < 2.7")
del sys
import unittest
from commissioning.clients.http import HTTP_API_Client
from commissioning import QuotaholderAPI
### DEFS ###
def new_quota_holder_client():
"""
Create a new quota holder api client
"""
class QuotaholderHTTP(HTTP_API_Client):
api_spec = QuotaholderAPI()
global QH_URL
return QuotaholderHTTP(QH_URL)
### VARS ###
QH_URL = "http://localhost:8008/api/quotaholder/v"
#!/usr/bin/python
from commissioning.clients.http import main, HTTP_API_Client
from commissioning import QuotaholderAPI
import unittest
QH_URL = "http://localhost:8008/api/quotaholder/v"
# We import our own unittest :)
from kkconfig import unittest
from kkconfig import new_quota_holder_client
class QuotaholderHTTP(HTTP_API_Client):
api_spec = QuotaholderAPI()
class QuotaHolderAPITest(unittest.TestCase):
class KKQuotaHolderAPITest(unittest.TestCase):
def setUp(self):
self.qh = QuotaholderHTTP(QH_URL)
self.qh = new_quota_holder_client()
def tearDown(self):
del self.qh
......@@ -70,6 +66,5 @@ class QuotaHolderAPITest(unittest.TestCase):
pass
if __name__ == "__main__":
unittest.main()
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