1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5#     http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from openstack.placement.v1 import resource_class as rc
14from openstack.tests.unit import base
15
16FAKE = {
17    'name': 'CUSTOM_FPGA',
18}
19
20
21class TestResourceClass(base.TestCase):
22
23    def test_basic(self):
24        sot = rc.ResourceClass()
25        self.assertEqual(None, sot.resource_key)
26        self.assertEqual('resource_classes', sot.resources_key)
27        self.assertEqual('/resource_classes', sot.base_path)
28        self.assertTrue(sot.allow_create)
29        self.assertTrue(sot.allow_fetch)
30        self.assertTrue(sot.allow_commit)
31        self.assertTrue(sot.allow_delete)
32        self.assertTrue(sot.allow_list)
33        self.assertFalse(sot.allow_patch)
34
35        self.assertDictEqual(
36            {'limit': 'limit', 'marker': 'marker'},
37            sot._query_mapping._mapping)
38
39    def test_make_it(self):
40        sot = rc.ResourceClass(**FAKE)
41        self.assertEqual(FAKE['name'], sot.id)
42        self.assertEqual(FAKE['name'], sot.name)
43