| 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_match |
| 15 |
---------- |
| 16 |
|
| 17 |
Tests for is_match logic |
| 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 testscenarios import load_tests_apply_scenarios as load_tests # noqa |
| 24 |
|
| 25 |
import os_service_types |
| 26 |
from os_service_types.tests import base |
| 27 |
|
| 28 |
|
| 29 |
class TestMatch(base.TestCase): |
| 30 |
scenarios = [ |
| 31 |
( |
| 32 |
'match-official', |
| 33 |
dict(requested='compute', found='compute', is_match=True), |
| 34 |
), |
| 35 |
( |
| 36 |
'direct-match-unknown', |
| 37 |
dict(requested='unknown', found='unknown', is_match=True), |
| 38 |
), |
| 39 |
( |
| 40 |
'volumev2-finds-block', |
| 41 |
dict(requested='volumev2', found='block-storage', is_match=True), |
| 42 |
), |
| 43 |
( |
| 44 |
'volumev3-finds-block', |
| 45 |
dict(requested='volumev3', found='block-storage', is_match=True), |
| 46 |
), |
| 47 |
( |
| 48 |
'block-finds-volumev2', |
| 49 |
dict(requested='block-storage', found='volumev2', is_match=True), |
| 50 |
), |
| 51 |
( |
| 52 |
'block-finds-volumev3', |
| 53 |
dict(requested='block-storage', found='volumev3', is_match=True), |
| 54 |
), |
| 55 |
( |
| 56 |
'volumev2-not-volumev3', |
| 57 |
dict(requested='volumev2', found='volumev3', is_match=False), |
| 58 |
), |
| 59 |
( |
| 60 |
'non-match', |
| 61 |
dict(requested='unknown', found='compute', is_match=False), |
| 62 |
), |
| 63 |
] |
| 64 |
|
| 65 |
def setUp(self): |
| 66 |
super().setUp() |
| 67 |
# Make an object with no network access |
| 68 |
self.service_types = os_service_types.ServiceTypes() |
| 69 |
|
| 70 |
def test_is_match(self): |
| 71 |
self.assertEqual( |
| 72 |
self.is_match, |
| 73 |
self.service_types.is_match(self.requested, self.found), |
| 74 |
) |