| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
from pycadf import cadftaxonomy |
| 15 |
from pycadf.helper import api |
| 16 |
from pycadf.tests import base |
| 17 |
|
| 18 |
|
| 19 |
class TestApiHelper(base.TestCase): |
| 20 |
def test_convert_req_action(self): |
| 21 |
self.assertEqual(cadftaxonomy.ACTION_READ, |
| 22 |
api.convert_req_action('get')) |
| 23 |
self.assertEqual(cadftaxonomy.ACTION_CREATE, |
| 24 |
api.convert_req_action('POST')) |
| 25 |
self.assertEqual(cadftaxonomy.ACTION_DELETE, |
| 26 |
api.convert_req_action('deLetE')) |
| 27 |
|
| 28 |
def test_convert_req_action_invalid(self): |
| 29 |
self.assertEqual(cadftaxonomy.UNKNOWN, api.convert_req_action(124)) |
| 30 |
self.assertEqual(cadftaxonomy.UNKNOWN, api.convert_req_action('blah')) |
| 31 |
|
| 32 |
def test_convert_req_action_with_details(self): |
| 33 |
detail = 'compute/instance' |
| 34 |
self.assertEqual(cadftaxonomy.ACTION_READ + '/%s' % detail, |
| 35 |
api.convert_req_action('GET', detail)) |
| 36 |
self.assertEqual(cadftaxonomy.ACTION_DELETE + '/%s' % detail, |
| 37 |
api.convert_req_action('DELETE', detail)) |
| 38 |
|
| 39 |
def test_convert_req_action_with_details_invalid(self): |
| 40 |
detail = 123 |
| 41 |
self.assertEqual(cadftaxonomy.ACTION_READ, |
| 42 |
api.convert_req_action('GET', detail)) |
| 43 |
self.assertEqual(cadftaxonomy.ACTION_DELETE, |
| 44 |
api.convert_req_action('DELETE', detail)) |