Changeset 7be94aa for src/mapservice/tests/test_config.py
- Timestamp:
- Apr 11, 2020, 4:46:15 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 3db3d13
- Parents:
- da2be70
- File:
-
- 1 edited
-
src/mapservice/tests/test_config.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/mapservice/tests/test_config.py
rda2be70 r7be94aa 23 23 from gnuboat_mapservice.server_impl import Config 24 24 25 25 26 class TestConfig(unittest.TestCase): 26 def test_config_from_file(self):27 """Test case load config from file27 def test_config_from_file(self): 28 """Test case load config from file 28 29 """ 29 new_config = { 30 'TESTING': True, 31 'DOES_NOT_EXISTS': 1234 32 } 33 34 config = Config.Config() 35 assert config.TESTING == False 36 37 config_file = tempfile.NamedTemporaryFile(mode='w', prefix='gnuboat-test-config', delete=False) 38 yaml.dump(new_config, config_file, default_flow_style=False, allow_unicode=True) 39 config_file.close() 40 config_file = os.path.join(tempfile.gettempdir(), config_file.name) 30 new_config = {'TESTING': True, 'DOES_NOT_EXISTS': 1234} 41 31 42 config = Config.load_from_file(config_file) 43 assert config.TESTING == True 44 assert config.DOES_NOT_EXISTS == 1234 45 os.remove(config_file) 32 config = Config.Config() 33 assert config.TESTING == False 34 35 config_file = tempfile.NamedTemporaryFile( 36 mode='w', prefix='gnuboat-test-config', delete=False 37 ) 38 yaml.dump( 39 new_config, 40 config_file, 41 default_flow_style=False, 42 allow_unicode=True 43 ) 44 config_file.close() 45 config_file = os.path.join(tempfile.gettempdir(), config_file.name) 46 47 config = Config.load_from_file(config_file) 48 assert config.TESTING == True 49 assert config.DOES_NOT_EXISTS == 1234 50 os.remove(config_file) 51 46 52 47 53 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.
