Statistics
| Branch: | Tag: | Revision:

root / test / apitest.py @ bec1fa3d

History | View | Annotate | Download (1.2 kB)

1
#!/usr/bin/python
2
from commissioning.clients.http import main, HTTP_API_Client
3
from commissioning import QuotaholderAPI
4
import unittest
5
import ConfigParser
6

    
7

    
8
class QuotaholderHTTP(HTTP_API_Client):
9
    api_spec = QuotaholderAPI()
10

    
11
class Config():
12
    def __init__(self):
13
        self.config = ConfigParser.RawConfigParser()
14
        self.cp.read_file("test.cfg")
15

    
16
    def module_config(mod):
17
        '''Loads the config residing next to the module.'''
18
        import shlex, os.path
19
        cp = ConfigParser.RawConfigParser()
20
        # ''' open(os.path.splitext(mod.__file__)[0] + '.conf')'''
21
        cp.read_file("test.cfg")
22
        return cp
23

    
24
class SimpleAPICall(unittest.TestCase):
25
    def setUp(self):
26
        print 'In setUp()'
27
        self.fixture = range(1, 10)
28
        QH_URL='http://localhost:8008/api/quotaholder/v'
29
        self.conf = module_config(__name__ + ".cfg")
30
        self.qh = QuotaholderHTTP(QH_URL)
31

    
32
    def tearDown(self):
33
        print 'In tearDown()'
34
        del self.qh
35

    
36
    def testCreate(self):
37
        rejected = self.qh.create_entity(context={},create_entity=[("pgerakios","system","key1","")])
38
        self.assertEqual(rejected,[])
39

    
40
if __name__ == "__main__":
41
    unittest.main()