Debian Codegraph @

pycadf/tests/helper/test_api.py

raw symbols SCIP
1 #
2 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
3 # use this file except in compliance with the License. You may obtain a copy of
4 # the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 # License for the specific language governing permissions and limitations under
12 # the License.
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))