Revision a812c719 test/kkconfig.py
b/test/kkconfig.py | ||
---|---|---|
1 | 1 |
### IMPORTS ### |
2 |
import sys |
|
3 |
import os |
|
2 | 4 |
# The following import is copied from snf-tools/syneffo_tools/burnin.py |
3 | 5 |
# Thank you John Giannelos <johngian@grnet.gr> |
4 | 6 |
# Use backported unittest functionality if Python < 2.7 |
5 | 7 |
try: |
6 | 8 |
import unittest2 as unittest |
7 | 9 |
except ImportError: |
8 |
import sys |
|
9 | 10 |
if sys.version_info < (2, 7): |
10 | 11 |
raise Exception("The unittest2 package is required for Python < 2.7") |
11 |
del sys |
|
12 | 12 |
import unittest |
13 | 13 |
|
14 | 14 |
from commissioning.clients.http import HTTP_API_Client |
... | ... | |
51 | 51 |
string += x |
52 | 52 |
return string |
53 | 53 |
|
54 |
def environ_get(key, default_value = ''): |
|
55 |
if os.environ.has_key(key): |
|
56 |
return (os.environ[key], True) |
|
57 |
else: |
|
58 |
return (default_value, False) |
|
59 |
|
|
60 |
def printf(fmt, *args): |
|
61 |
print(fmt.format(*args)) |
|
62 |
|
|
54 | 63 |
### CLASSES ### |
55 | 64 |
class QHTestCase(unittest.TestCase): |
56 | 65 |
def setUp(self): |
... | ... | |
61 | 70 |
|
62 | 71 |
|
63 | 72 |
### VARS ### |
64 |
QH_URL = "http://localhost:8008/api/quotaholder/v" |
|
73 |
DefaultOrCustom = { |
|
74 |
True: "default", |
|
75 |
False: "custom" |
|
76 |
} |
|
77 |
|
|
78 |
QH_HOST, qh_using_default_host = environ_get("TEST_QH_HOST", "127.0.0.1") |
|
79 |
QH_PORT, qh_using_default_port = environ_get("TEST_QH_PORT", "35080") |
|
80 |
|
|
81 |
printf("Will connect to QH_HOST = {0} [{1}]", QH_HOST, DefaultOrCustom[qh_using_default_host]) |
|
82 |
printf(" and QH_PORT = {0} [{1}]", QH_PORT, DefaultOrCustom[qh_using_default_port]) |
|
83 |
|
|
84 |
QH_URL = "http://{0}:{1}/api/quotaholder/v".format(QH_HOST, QH_PORT) |
Also available in: Unified diff