root / test / apitest.py @ b9ec4de7
History | View | Annotate | Download (2.3 kB)
1 | bec1fa3d | Prodromos Gerakios | #!/usr/bin/python
|
---|---|---|---|
2 | bec1fa3d | Prodromos Gerakios | from commissioning.clients.http import main, HTTP_API_Client |
3 | bec1fa3d | Prodromos Gerakios | from commissioning import QuotaholderAPI |
4 | bec1fa3d | Prodromos Gerakios | import unittest |
5 | bec1fa3d | Prodromos Gerakios | import ConfigParser |
6 | bec1fa3d | Prodromos Gerakios | |
7 | bec1fa3d | Prodromos Gerakios | |
8 | bec1fa3d | Prodromos Gerakios | class QuotaholderHTTP(HTTP_API_Client): |
9 | bec1fa3d | Prodromos Gerakios | api_spec = QuotaholderAPI() |
10 | bec1fa3d | Prodromos Gerakios | |
11 | bec1fa3d | Prodromos Gerakios | class Config(): |
12 | bec1fa3d | Prodromos Gerakios | def __init__(self): |
13 | 2fa15cf2 | Christos KK Loverdos | config = ConfigParser.RawConfigParser() |
14 | 2fa15cf2 | Christos KK Loverdos | read_ok = config.read("apitest.cfg")
|
15 | 2fa15cf2 | Christos KK Loverdos | if not read_ok: |
16 | 2fa15cf2 | Christos KK Loverdos | pass # raise something? |
17 | 2fa15cf2 | Christos KK Loverdos | self.qh_url = config.get('global', 'QH_URL') |
18 | 2fa15cf2 | Christos KK Loverdos | self.qh = QuotaholderHTTP(self.qh_url) |
19 | 2fa15cf2 | Christos KK Loverdos | |
20 | bec1fa3d | Prodromos Gerakios | |
21 | bec1fa3d | Prodromos Gerakios | def module_config(mod): |
22 | bec1fa3d | Prodromos Gerakios | '''Loads the config residing next to the module.'''
|
23 | bec1fa3d | Prodromos Gerakios | import shlex, os.path |
24 | bec1fa3d | Prodromos Gerakios | cp = ConfigParser.RawConfigParser() |
25 | bec1fa3d | Prodromos Gerakios | # ''' open(os.path.splitext(mod.__file__)[0] + '.conf')'''
|
26 | bec1fa3d | Prodromos Gerakios | cp.read_file("test.cfg")
|
27 | bec1fa3d | Prodromos Gerakios | return cp
|
28 | bec1fa3d | Prodromos Gerakios | |
29 | bec1fa3d | Prodromos Gerakios | class SimpleAPICall(unittest.TestCase): |
30 | bec1fa3d | Prodromos Gerakios | def setUp(self): |
31 | 2fa15cf2 | Christos KK Loverdos | # print 'In setUp()'
|
32 | 2fa15cf2 | Christos KK Loverdos | # self.fixture = range(1, 10)
|
33 | 2fa15cf2 | Christos KK Loverdos | # QH_URL='http://localhost:8008/api/quotaholder/v'
|
34 | 2fa15cf2 | Christos KK Loverdos | # self.conf = module_config(__name__ + ".cfg")
|
35 | 2fa15cf2 | Christos KK Loverdos | # self.qh = QuotaholderHTTP(QH_URL)
|
36 | 2fa15cf2 | Christos KK Loverdos | config = Config() |
37 | 2fa15cf2 | Christos KK Loverdos | self.qh = config.qh
|
38 | 2fa15cf2 | Christos KK Loverdos | print self.qh |
39 | bec1fa3d | Prodromos Gerakios | |
40 | bec1fa3d | Prodromos Gerakios | def tearDown(self): |
41 | 2fa15cf2 | Christos KK Loverdos | # print 'In tearDown()'
|
42 | bec1fa3d | Prodromos Gerakios | del self.qh |
43 | bec1fa3d | Prodromos Gerakios | |
44 | 16414815 | Christos KK Loverdos | def test_001_create_entity(self): |
45 | bec1fa3d | Prodromos Gerakios | rejected = self.qh.create_entity(context={},create_entity=[("pgerakios","system","key1","")]) |
46 | bec1fa3d | Prodromos Gerakios | self.assertEqual(rejected,[])
|
47 | bec1fa3d | Prodromos Gerakios | |
48 | 16414815 | Christos KK Loverdos | def test_002_set_entity_key(self): |
49 | 16414815 | Christos KK Loverdos | pass
|
50 | 16414815 | Christos KK Loverdos | |
51 | 16414815 | Christos KK Loverdos | def test_003_list_entities(self): |
52 | 16414815 | Christos KK Loverdos | pass
|
53 | 16414815 | Christos KK Loverdos | |
54 | 16414815 | Christos KK Loverdos | def test_004_get_entity(self): |
55 | 16414815 | Christos KK Loverdos | pass
|
56 | 16414815 | Christos KK Loverdos | |
57 | 16414815 | Christos KK Loverdos | def test_005_get_limits(self): |
58 | 16414815 | Christos KK Loverdos | pass
|
59 | 16414815 | Christos KK Loverdos | |
60 | 16414815 | Christos KK Loverdos | def test_006_set_limits(self): |
61 | 16414815 | Christos KK Loverdos | pass
|
62 | 16414815 | Christos KK Loverdos | |
63 | 16414815 | Christos KK Loverdos | def test_007_get_holding(self): |
64 | 16414815 | Christos KK Loverdos | pass
|
65 | 16414815 | Christos KK Loverdos | |
66 | 16414815 | Christos KK Loverdos | def test_008_set_holding(self): |
67 | 16414815 | Christos KK Loverdos | pass
|
68 | 16414815 | Christos KK Loverdos | |
69 | 16414815 | Christos KK Loverdos | def test_009_list_resources(self): |
70 | 16414815 | Christos KK Loverdos | pass
|
71 | 16414815 | Christos KK Loverdos | |
72 | 16414815 | Christos KK Loverdos | def test_010_get_quota(self): |
73 | 16414815 | Christos KK Loverdos | pass
|
74 | 16414815 | Christos KK Loverdos | |
75 | 16414815 | Christos KK Loverdos | def test_011_set_quota(self): |
76 | 16414815 | Christos KK Loverdos | pass
|
77 | 16414815 | Christos KK Loverdos | |
78 | 16414815 | Christos KK Loverdos | def test_012_issue_commission(self): |
79 | 16414815 | Christos KK Loverdos | pass
|
80 | 16414815 | Christos KK Loverdos | |
81 | 16414815 | Christos KK Loverdos | def test_013_accept_commission(self): |
82 | 16414815 | Christos KK Loverdos | pass
|
83 | 16414815 | Christos KK Loverdos | |
84 | 16414815 | Christos KK Loverdos | def test_014_reject_commission(self): |
85 | 16414815 | Christos KK Loverdos | pass
|
86 | 16414815 | Christos KK Loverdos | |
87 | 16414815 | Christos KK Loverdos | def test_015_get_pending_commissions(self): |
88 | 16414815 | Christos KK Loverdos | pass
|
89 | 16414815 | Christos KK Loverdos | |
90 | 16414815 | Christos KK Loverdos | def test_016_resolve_pending_commissions(self): |
91 | 16414815 | Christos KK Loverdos | pass
|
92 | 16414815 | Christos KK Loverdos | |
93 | 16414815 | Christos KK Loverdos | def test_017_release_entity(self): |
94 | 16414815 | Christos KK Loverdos | pass
|
95 | 16414815 | Christos KK Loverdos | |
96 | 16414815 | Christos KK Loverdos | def test_018_get_timeline(self): |
97 | 16414815 | Christos KK Loverdos | pass
|
98 | 16414815 | Christos KK Loverdos | |
99 | 16414815 | Christos KK Loverdos | |
100 | 16414815 | Christos KK Loverdos | |
101 | bec1fa3d | Prodromos Gerakios | if __name__ == "__main__": |
102 | bec1fa3d | Prodromos Gerakios | unittest.main() |