| 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_singleton |
| 15 |
------------ |
| 16 |
|
| 17 |
Tests for `get_service_types` singleton factory function. |
| 18 |
""" |
| 19 |
|
| 20 |
import os_service_types |
| 21 |
from os_service_types.tests import base |
| 22 |
|
| 23 |
|
| 24 |
class TestSingleton(base.TestCase): |
| 25 |
def setUp(self): |
| 26 |
super().setUp() |
| 27 |
# Make an object with no network access |
| 28 |
self.service_types = os_service_types.get_service_types() |
| 29 |
|
| 30 |
def test_singleton_same(self): |
| 31 |
service_types = os_service_types.get_service_types() |
| 32 |
self.assertTrue(service_types is self.service_types) |
| 33 |
|
| 34 |
def test_singleton_different(self): |
| 35 |
service_types = os_service_types.ServiceTypes() |
| 36 |
self.assertFalse(service_types is self.service_types) |