Skip to content

Commit 7a25a7f

Browse files
committed
Added more tests
1 parent abc469a commit 7a25a7f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

tests/tests_config.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import os
33
import unittest
44

5+
from pyms.config.conf import Config
6+
57
from pyms.config.confile import ConfFile
68
from pyms.constants import CONFIGMAP_FILE_ENVIRONMENT, LOGGER_NAME
7-
from pyms.exceptions import AttrDoesNotExistException, ConfigDoesNotFoundException
9+
from pyms.exceptions import AttrDoesNotExistException, ConfigDoesNotFoundException, ServiceDoesNotExistException
810

911
logger = logging.getLogger(LOGGER_NAME)
1012

@@ -68,6 +70,22 @@ def test_example_test_json_file(self):
6870
self.assertEqual(config.my_ms.test_var, "general")
6971

7072

73+
class ConfServiceTests(unittest.TestCase):
74+
75+
def test_config_with_service(self):
76+
class MyService(Config):
77+
service = "service"
78+
79+
config = MyService()
80+
configuration = config.config(config={"service": {"service1": "a", "service2": "b"}})
81+
self.assertEqual(configuration.service1, "a")
82+
83+
def test_config_with_service_not_exist(self):
84+
config = Config()
85+
with self.assertRaises(ServiceDoesNotExistException):
86+
configuration = config.config(config={"service": {"service1": "a", "service2": "b"}})
87+
88+
7189
class ConfNotExistTests(unittest.TestCase):
7290
def test_empty_conf(self):
7391
config = ConfFile(empty_init=True)
@@ -79,4 +97,4 @@ def test_empty_conf_two_levels(self):
7997

8098
def test_empty_conf_three_levels(self):
8199
config = ConfFile(empty_init=True)
82-
self.assertEqual(config.my_ms.level_two.level_three, {})
100+
self.assertEqual(config.my_ms.level_two.level_three, {})

0 commit comments

Comments
 (0)