Revision a812c719
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) |
b/test/limits.py | ||
---|---|---|
1 | 1 |
from kkconfig import QHTestCase |
2 | 2 |
from kkconfig import run_test_case |
3 |
from kkconfig import printf |
|
3 | 4 |
|
4 | 5 |
class LimitsTest(QHTestCase): |
5 | 6 |
def test_01_set_get(self): |
... | ... | |
22 | 23 |
# GET |
23 | 24 |
limits = self.qh.get_limits( |
24 | 25 |
context = {}, |
25 |
get_limits = [(policy, )] # or is it just policy, i.e. no
|
|
26 |
get_limits = [policy] # or is it just policy, i.e. no
|
|
26 | 27 |
) |
27 | 28 |
|
28 |
self.assertTrue(len(limits) > 1)
|
|
29 |
self.assertTrue(len(limits) == 1)
|
|
29 | 30 |
|
30 | 31 |
if __name__ == "__main__": |
31 | 32 |
import sys |
32 |
print("Using {0}".format(sys.executable))
|
|
33 |
printf("Using {0}", sys.executable)
|
|
33 | 34 |
run_test_case(LimitsTest) |
Also available in: Unified diff