Skip to content

Commit

Permalink
Add a simple CLI test for phonon website json output
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjackson committed Oct 22, 2024
1 parent 3e53294 commit fd0ad50
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests_and_analysis/test/script_tests/test_dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ def test_plot_save_to_json(self, inject_mocks, tmpdir, dispersion_args):
spec = Spectrum1DCollection.from_json_file(output_file)
assert isinstance(spec, Spectrum1DCollection)

@pytest.mark.parametrize('dispersion_args', [
[quartz_json_file, '--save-web-json']])
def test_plot_save_to_web_json(self, inject_mocks, tmpdir, dispersion_args):

Check notice on line 131 in tests_and_analysis/test/script_tests/test_dispersion.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests_and_analysis/test/script_tests/test_dispersion.py#L131

Missing function or method docstring

Check warning on line 131 in tests_and_analysis/test/script_tests/test_dispersion.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests_and_analysis/test/script_tests/test_dispersion.py#L131

Unused argument 'inject_mocks'
output_file = str(tmpdir.join('phonon.json'))
euphonic.cli.dispersion.main(dispersion_args + [output_file])

with open(output_file, "r", encoding="utf-8") as fd:
dat = json.load(fd)

# Reloaded JSON doesn't quite match the PhononWebsiteData type because
# tuples are converted to int; just make sure _some_ of the data is
# here so CLI writes the correct file. Unit tests check correctness.
assert "line_breaks" in dat

@pytest.mark.parametrize('dispersion_args', [
[quartz_no_evec_json_file, '--reorder']])
def test_no_evecs_with_reorder_raises_type_error(self, dispersion_args):
Expand Down

0 comments on commit fd0ad50

Please sign in to comment.