''' Copyright (C) 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ''' import unittest import tempfile import yaml import os from gnuboat_mapservice.server_impl import Config class TestConfig(unittest.TestCase): def test_config_from_file(self): """Test case load config from file """ new_config = {'TESTING': True, 'DOES_NOT_EXISTS': 1234} config = Config.Config() assert config.TESTING == False config_file = tempfile.NamedTemporaryFile( mode='w', prefix='gnuboat-test-config', delete=False ) yaml.dump( new_config, config_file, default_flow_style=False, allow_unicode=True ) config_file.close() config_file = os.path.join(tempfile.gettempdir(), config_file.name) config = Config.load_from_file(config_file) assert config.TESTING == True assert config.DOES_NOT_EXISTS == 1234 os.remove(config_file) if __name__ == '__main__': unittest.main()