Merge "vnf_generic: convert sshmanager to class"
[yardstick.git] / tests / unit / apiserver / __init__.py
1 from __future__ import absolute_import
2
3 import os
4 import unittest
5 import tempfile
6
7 from oslo_serialization import jsonutils
8
9 from yardstick.common import constants as consts
10
11
12 class APITestCase(unittest.TestCase):
13
14     def setUp(self):
15         self.db_fd, self.db_path = tempfile.mkstemp()
16         consts.SQLITE = 'sqlite:///{}'.format(self.db_path)
17         from api import server
18
19         server.app.config['TESTING'] = True
20         self.app = server.app.test_client()
21
22         server.init_db()
23
24     def tearDown(self):
25         os.close(self.db_fd)
26         os.unlink(self.db_path)
27
28     def _post(self, url, data):
29         headers = {'Content-Type': 'application/json'}
30         resp = self.app.post(url, data=jsonutils.dumps(data), headers=headers)
31         return jsonutils.loads(resp.data)
32
33     def _get(self, url):
34         resp = self.app.get(url)
35         return jsonutils.loads(resp.data)