Exemple #1
0
    def test_update_config(self):
        write_config(ORIGINAL_CONFIG)
        server = ShorthandServer(server_config_path)

        # Test a valid update
        update = {
            'log_level': 'WARNING',
            'frontend': {
                'view_history_limit': 500,
                'map_tileserver_url': 'https://{s}.site.com/{z}/{x}/{y}.png'
            }
        }
        server.update_config(update)
        updated_config = server.get_config()
        assert updated_config['log_level'] == update['log_level']
        assert updated_config['frontend'] == update['frontend']

        # Test an invalid update
        bad_update = {
            'log_level': 'INVALID'
        }
        with pytest.raises(ValueError) as e:
            server.update_config(bad_update)
        assert str(e.value)
        assert updated_config['log_level'] == update['log_level']
        assert updated_config['frontend'] == update['frontend']
Exemple #2
0
    def test_save_config(self):
        write_config(ORIGINAL_CONFIG)
        server = ShorthandServer(server_config_path)

        # Test a valid update
        update = {
            'log_level': 'WARNING',
            'frontend': {
                'view_history_limit': 500,
                'map_tileserver_url': 'https://{s}.site.com/{z}/{x}/{y}.png'
            }
        }
        server.update_config(update)
        server.save_config()
        with open(server_config_path, 'r') as config_file_object:
            config = json.load(config_file_object)
        assert config['log_level'] == update['log_level']
        assert config['frontend'] == update['frontend']