File: test_plugin.py

package info (click to toggle)
python-osc-placement 4.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 640 kB
  • sloc: python: 4,039; makefile: 25; sh: 2
file content (43 lines) | stat: -rw-r--r-- 1,592 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import argparse
from unittest import mock

from oslotest import base

import osc_placement.plugin as plugin


class TestPlugin(base.BaseTestCase):
    def test_build_option_parser(self):
        parser = plugin.build_option_parser(argparse.ArgumentParser())

        args = parser.parse_args(['--os-placement-api-version=1.0'])
        self.assertEqual('1.0', args.os_placement_api_version)
        args = parser.parse_args(['--os-placement-api-version', '1.0'])
        self.assertEqual('1.0', args.os_placement_api_version)

    @mock.patch('osc_placement.http.SessionClient')
    def test_make_client(self, mock_session_client):
        instance = mock.Mock(_api_version={'placement': '1.0'})

        plugin.make_client(instance)
        mock_session_client.assert_called_with(
            session=instance.session,
            ks_filter={
                'service_type': 'placement',
                'region_name': instance._region_name,
                'interface': instance.interface
            },
            api_version='1.0'
        )