diff --git a/tests/unit/readers/ppf_samples.json b/tests/unit/readers/ppf_samples.json index e7edd2c2..f009926a 100644 --- a/tests/unit/readers/ppf_samples.json +++ b/tests/unit/readers/ppf_samples.json @@ -3623,5 +3623,37 @@ "min": 0, "max": 0.5, "dtype": "float64" + }, + "cwuv/n_w": { + "shape": [ + 33 + ], + "min": 0, + "max": 1000, + "dtype": "float64" + }, + "cwuv/c_w": { + "shape": [ + 33 + ], + "min": 0, + "max": 1, + "dtype": "float64" + }, + "cwup/n_w": { + "shape": [ + 33 + ], + "min": 0, + "max": 1000, + "dtype": "float64" + }, + "cwup/c_w": { + "shape": [ + 33 + ], + "min": 0, + "max": 1, + "dtype": "float64" } } diff --git a/tests/unit/readers/test_ppf_reader.py b/tests/unit/readers/test_ppf_reader.py index e5861071..74dcee40 100644 --- a/tests/unit/readers/test_ppf_reader.py +++ b/tests/unit/readers/test_ppf_reader.py @@ -646,6 +646,74 @@ def test_get_bremsstrahlung_spectroscopy( ) +@given( + integers(28792, 99999), + times, + errors, + max_freqs, + just("jetppf"), + sampled_from(["cwup", "cwuv"]), + revisions, + edited_revisions, + lists( + sampled_from(list(PPFReader.available_quantities("cwup").keys())), + min_size=1, + unique=True, + ).map(set), +) +def test_get_vuv_w_analyser( + pulse, + time_range, + error, + freq, + uid, + instrument, + revision, + available_revisions, + quantities, +): + """ + Test data returned by _get_vuv_w_analyser is correct. + """ + reader = patched_ppf_reader( + pulse, + *time_range, + default_error=error, + max_freq=freq, + selector=MagicMock(), + session=MagicMock(), + ) + mock_surf = MagicMock( + return_value=( + np.array([0]), + np.array([0]), + np.array([1]), + np.array([1]), + np.array([0]), + np.array([0]), + ) + ) + reader._client._revisions = available_revisions + bad_rev = revision != 0 and revision < available_revisions[0] + + with patch("indica.readers.surf_los.read_surf_los", mock_surf), pytest.raises( + sal.core.exception.NodeNotFound + ) if bad_rev else nullcontext(): + results = reader._get_vuv_w_analyser(uid, instrument, revision, quantities) + if bad_rev: + return + + assert results["machine_dims"] == ((1.83, 3.9), (-1.75, 2.0)) + for q in quantities: + signal = reader._client.construct_signal(f"{instrument}/{q}") + assert np.all(results[q] == signal.data) + assert np.all(results["times"] == signal.dimensions[0].data) + assert results[q + "_xstart"].shape == (1,) + assert results[q + "_xstop"].shape == (1,) + assert results[q + "_zstart"].shape == (1,) + assert results[q + "_zstop"].shape == (1,) + + @given( pulses, times, @@ -654,7 +722,7 @@ def test_get_bremsstrahlung_spectroscopy( text(min_size=1), sampled_from(sorted(PPFReader.INSTRUMENT_METHODS.keys())), revisions, - lists(text(), min_size=1, unique=True).map(set), + lists(text(min_size=1), min_size=1, unique=True).map(set), ) def test_general_get( pulse, time_range, error, freq, uid, instrument, revision, quantities @@ -668,6 +736,7 @@ def test_general_get( get_cyclotron_emissions=DEFAULT, get_radiation=DEFAULT, get_bremsstrahlung_spectroscopy=DEFAULT, + get_vuv_w_analyser=DEFAULT, ), patch("indica.readers.ppfreader.SALClient", JETFakeSALClient): reader = PPFReader( pulse,