22import os
33import unittest
44
5+ from pyms .config .conf import Config
6+
57from pyms .config .confile import ConfFile
68from pyms .constants import CONFIGMAP_FILE_ENVIRONMENT , LOGGER_NAME
7- from pyms .exceptions import AttrDoesNotExistException , ConfigDoesNotFoundException
9+ from pyms .exceptions import AttrDoesNotExistException , ConfigDoesNotFoundException , ServiceDoesNotExistException
810
911logger = 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+
7189class 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