Debian Codegraph @

os_service_types/tests/test_remote.py

raw
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
13 """
14 test_remote
15 -----------
16
17 Tests for `ServiceTypes` class remote data.
18
19 oslotest sets up a TempHomeDir for us, so there should be no ~/.cache files
20 available in these tests.
21 """
22
23 from requests_mock.contrib import fixture as rm_fixture
24 from testscenarios import load_tests_apply_scenarios as load_tests # noqa
25
26 import keystoneauth1.session
27
28 import os_service_types
29 import os_service_types.service_types
30 from os_service_types.tests import base
31
32
33 class TestRemote(base._BaseServiceDataTest):
34 def setUp(self):
35 super().setUp()
36 # Set up a requests_mock fixture for all HTTP traffic
37 adapter = self.useFixture(rm_fixture.Fixture())
38 adapter.register_uri(
39 'GET',
40 os_service_types.service_types.SERVICE_TYPES_URL,
41 json=self.remote_content,
42 headers={'etag': self.getUniqueString('etag')},
43 )
44 # use keystoneauth1 to get a Sessiom with no auth information
45 self.session = keystoneauth1.session.Session()
46 # Make an object that fetches from the network
47 self.service_types = os_service_types.ServiceTypes(
48 session=self.session
49 )
50 self.assertEqual(1, len(adapter.request_history))
51
52 def test_remote_version(self):
53 self.assertEqual(self.remote_version, self.service_types.version)