mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-01 18:47:48 +00:00
This change siplifies the structure of the simulation parameters, removing the gnpy.science_utils.simulation layer, provides some documentation of the parameters and define a mock fixture for testing in safe mode. Jan: while I'm not thrilled by this concept of hidden global state, we agreed to let it in as a temporary measure (so as not to hold merging of Andrea's flexgrid/multirate patches). I've refactored this to a more pytest-ish way of dealing with fixtures. In the end, it was also possible to remove the MockSimParams class because it was not adding any features on top of what SimParams can do already (and to what was tested). Change-Id: If5ef341e0585586127d5dae3f39dca2c232236f1 Signed-off-by: Jan Kundrát <jan.kundrat@telecominfraproject.com>
24 lines
631 B
Python
24 lines
631 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Checks that the class SimParams behaves as a mutable Singleton.
|
|
"""
|
|
|
|
import pytest
|
|
from gnpy.core.parameters import SimParams
|
|
|
|
|
|
@pytest.mark.usefixtures('set_sim_params')
|
|
def test_sim_parameters():
|
|
sim_params = {'nli_params': {}, 'raman_params': {}}
|
|
SimParams.set_params(sim_params)
|
|
s1 = SimParams.get()
|
|
assert s1.nli_params.method == 'gn_model_analytic'
|
|
s2 = SimParams.get()
|
|
assert not s1.raman_params.flag
|
|
sim_params['raman_params']['flag'] = True
|
|
SimParams.set_params(sim_params)
|
|
assert s2.raman_params.flag
|
|
assert s1.raman_params.flag
|