root / test / kkconfig.py @ f611ef3d
History | View | Annotate | Download (1.2 kB)
1 |
### IMPORTS ###
|
---|---|
2 |
# The following import is copied from snf-tools/syneffo_tools/burnin.py
|
3 |
# Thank you John Giannelos <johngian@grnet.gr>
|
4 |
# Use backported unittest functionality if Python < 2.7
|
5 |
try:
|
6 |
import unittest2 as unittest |
7 |
except ImportError: |
8 |
import sys |
9 |
if sys.version_info < (2, 7): |
10 |
raise Exception("The unittest2 package is required for Python < 2.7") |
11 |
del sys
|
12 |
import unittest |
13 |
|
14 |
from commissioning.clients.http import HTTP_API_Client |
15 |
from commissioning import QuotaholderAPI |
16 |
import random |
17 |
|
18 |
### DEFS ###
|
19 |
def new_quota_holder_client(): |
20 |
"""
|
21 |
Create a new quota holder api client
|
22 |
"""
|
23 |
class QuotaholderHTTP(HTTP_API_Client): |
24 |
api_spec = QuotaholderAPI() |
25 |
|
26 |
global QH_URL
|
27 |
return QuotaholderHTTP(QH_URL)
|
28 |
|
29 |
def rand_string(): |
30 |
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
31 |
min = 5
|
32 |
max = 15
|
33 |
string=''
|
34 |
for x in random.sample(alphabet,random.randint(min,max)): |
35 |
string += x |
36 |
return string
|
37 |
|
38 |
### CLASSES ###
|
39 |
class QHTestCase(unittest.TestCase): |
40 |
def setUp(self): |
41 |
self.qh = new_quota_holder_client()
|
42 |
|
43 |
def tearDown(self): |
44 |
del self.qh |
45 |
|
46 |
|
47 |
### VARS ###
|
48 |
QH_URL = "http://localhost:8008/api/quotaholder/v"
|