diff --git a/pyproject.toml b/pyproject.toml index 5841189..30ac101 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,8 +61,6 @@ testpaths = "tests" addopts = "--cov -v" filterwarnings = 'ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning' # 3rd party - - [tool.box] builder = "rye" app_entry = "rimsschemedrawer.app:run_gui" diff --git a/tests/data/draw_last_false.json b/tests/data/draw_last_false.json new file mode 100644 index 0000000..ccdce3c --- /dev/null +++ b/tests/data/draw_last_false.json @@ -0,0 +1,67 @@ +{ + "scheme": { + "element": "Fe", + "gs_level": "0.0", + "gs_term": "5D4", + "ip_term": "", + "lasers": "Ti:Sa", + "last_step_to_ip": true, + "step_forbidden0": false, + "step_forbidden1": false, + "step_forbidden2": false, + "step_forbidden3": false, + "step_forbidden4": false, + "step_forbidden5": false, + "step_forbidden6": false, + "step_level0": "26140.196", + "step_level1": "50530.829", + "step_level2": "64126.024", + "step_level3": "", + "step_level4": "", + "step_level5": "", + "step_level6": "", + "step_lowlying0": false, + "step_lowlying1": false, + "step_lowlying2": false, + "step_lowlying3": false, + "step_lowlying4": false, + "step_lowlying5": false, + "step_lowlying6": false, + "step_term0": "5D3", + "step_term1": "5D3", + "step_term2": "", + "step_term3": "", + "step_term4": "", + "step_term5": "", + "step_term6": "", + "trans_strength0": "", + "trans_strength1": "", + "trans_strength2": "", + "trans_strength3": "", + "trans_strength4": "", + "trans_strength5": "", + "trans_strength6": "", + "unit": "cm-1" + }, + "settings": { + "arrow_head_width": "0.6", + "arrow_width": "0.2", + "fig_height": "8.0", + "fig_width": "5.0", + "fs_axes": "11.0", + "fs_axes_labels": "11.0", + "fs_labels": "11.0", + "fs_title": "14.0", + "headspace": "2500.0", + "ip_label_pos": "Bottom", + "line_breaks": true, + "plot_style": "light", + "plot_title": "", + "prec_level": "0", + "prec_wavelength": "3", + "show_cm-1_axis": true, + "show_eV_axis": true, + "show_forbidden_transitions": "x-out", + "show_transition_strength": true + } +} diff --git a/tests/data/draw_last_true.json b/tests/data/draw_last_true.json new file mode 100644 index 0000000..50fb10d --- /dev/null +++ b/tests/data/draw_last_true.json @@ -0,0 +1,67 @@ +{ + "scheme": { + "element": "Fe", + "gs_level": "0.0", + "gs_term": "5D4", + "ip_term": "", + "lasers": "Ti:Sa", + "last_step_to_ip": true, + "step_forbidden0": false, + "step_forbidden1": false, + "step_forbidden2": false, + "step_forbidden3": false, + "step_forbidden4": false, + "step_forbidden5": false, + "step_forbidden6": false, + "step_level0": "26140.196", + "step_level1": "50530.829", + "step_level2": "", + "step_level3": "", + "step_level4": "", + "step_level5": "", + "step_level6": "", + "step_lowlying0": false, + "step_lowlying1": false, + "step_lowlying2": false, + "step_lowlying3": false, + "step_lowlying4": false, + "step_lowlying5": false, + "step_lowlying6": false, + "step_term0": "5D3", + "step_term1": "5D3", + "step_term2": "", + "step_term3": "", + "step_term4": "", + "step_term5": "", + "step_term6": "", + "trans_strength0": "", + "trans_strength1": "", + "trans_strength2": "", + "trans_strength3": "", + "trans_strength4": "", + "trans_strength5": "", + "trans_strength6": "", + "unit": "cm-1" + }, + "settings": { + "arrow_head_width": "0.6", + "arrow_width": "0.2", + "fig_height": "8.0", + "fig_width": "5.0", + "fs_axes": "11.0", + "fs_axes_labels": "11.0", + "fs_labels": "11.0", + "fs_title": "14.0", + "headspace": "2500.0", + "ip_label_pos": "Bottom", + "line_breaks": true, + "plot_style": "light", + "plot_title": "", + "prec_level": "0", + "prec_wavelength": "3", + "show_cm-1_axis": true, + "show_eV_axis": true, + "show_forbidden_transitions": "x-out", + "show_transition_strength": true + } +} diff --git a/tests/test_json_parser.py b/tests/test_json_parser.py index e961191..4af4e92 100644 --- a/tests/test_json_parser.py +++ b/tests/test_json_parser.py @@ -18,6 +18,8 @@ def test_config_parser(data_path, fname): parser = jp.ConfigParser(data) assert parser.lasers == "Ti:Sa" + assert not parser.last_step_to_ip_mode + assert not parser.last_step_to_ip @pytest.mark.parametrize( @@ -118,3 +120,18 @@ def test_json_reader_new(data_path, tmp_path): assert isinstance(data_in, dict) assert "scheme" in data_in.keys() assert "settings" in data_in.keys() + + +@pytest.mark.parametrize("selector", [True, False]) +def test_json_reader_last_step_to_ip(data_path, selector): + """Check if last step to IP is correctly parsed.""" + if selector: + fin = data_path.joinpath("draw_last_true.json") + else: + fin = data_path.joinpath("draw_last_false.json") + data = jp.json_reader(fin) + + parser = jp.ConfigParser(data) + + assert parser.last_step_to_ip + assert parser.last_step_to_ip_mode is selector