Add tests for chart data

Issue #686 new
David Platten created an issue

It would be extremely useful to have tests to check that chart output for each modality is as expected for each type of chart, including filtering in a variety of ways.

Ensure there is some testing of chart data that has been filtered by acquisition name to ensure that a study-level chart contains the correct number of studies when a study contains more than one acquisition of the same name.

The table below contains a list of the basic chart types contained in OpenREM and an indication of whether there is test coverage for at least one chart of that type and where the test code is located, correct as of 20/2/2024. Every basic chart type is tested at least once.

Type of chart File test code located in Function name(s) of test Modalities covered by the test
Bar chart, mean test_charts_common.py check_series_and_category_names; check_average_data; check_avg_and_counts CT, DX, MG
Bar chart, median test_charts_common.py check_series_and_category_names; check_average_data; check_avg_and_counts CT, DX, MG
Bar chart, frequency test_charts_common.py check_series_and_category_names; check_frequency_data; check_frequencies CT, DX, MG
Box plot test_charts_common.py check_boxplot_data; check_boxplot_xy CT, DX, MG
Histogram test_charts_mg.py; test_charts_ct.py test_acq_agd_histogram; test_acq_dlp CT, MG
Line chart over time, mean test_charts_dx.py test_acquisition_dap_over_time; test_acquisition_kvp_over_time; test_acquisition_mas_over_time DX
Line chart over time, median test_charts_dx.py test_acquisition_dap_over_time; test_acquisition_kvp_over_time; test_acquisition_mas_over_time DX
Scatter chart test_charts_mg.py test_agd_vs_cbt; test_kvp_vs_cbt; test_mas_vs_cbt MG
Bar chart, workload test_charts_common.py check_workload_data MG
Bar chart, AGD vs compressed breast thickness test_charts_common.py check_sys_name_x_y_data MG
Bar chart, average AGD vs compressed breast thickness test_charts_common.py check_sys_name_x_y_data MG

Comments (55)

  1. David Platten reporter

    Added skeleton dx chart test file. Also amended an except in view.py to ensure that data is still created on KeyError. References issue #686

    → <<cset fa3eb598e73b>>

  2. David Platten reporter

    The tests work OK for me locally

    python manage.py test remapp.tests.test_charts_dx

    I'll try setting an SQLite database later to see if it works with that.

  3. David Platten reporter

    Added some specific tests for acquisition DAP mean, count, names and histogram data. These tests work on my local system. References issue #686

    → <<cset a5e173b382ce>>

  4. Ed McDonagh

    Not sure what is going on, and I don't know if this is the best way of doing it or not, but it works now @dplatten!

    I think testing a view is good if you want to inspect the resulting html - that is what we do with for example test_filters_ct

    Then we have non-Django specific web testing tools that allow testing automated pointing and clicking, which I had been thinking might be good for all the charts?

    And then we have the approach you have taken to get the data that is fed into the charts.

    I don't know that any one is the best way -- I think in time we need some of all of them!

  5. David Platten reporter

    Many thanks for getting this to work. I can now concentrate on putting together tests that will cover all the chart types for each modality using a range of filters.

  6. David Platten reporter

    For DX I still need to add:

    • case-insensitive test
    • workload chart
    • DAP over time chart
    • kVp over time chart
    • mAs over time chart
    • frequency chart test (done)
    • study-level bar chart test (done)
    • request-level bar chart test (done)
    • kVp acquisition chart (done)
    • mAs acquisition chart (done)
  7. David Platten reporter

    Farmed some common code into their own methods to reduce duplication and make it a little clearer what each test is actually trying to test. References issue #686

    → <<cset 588c79dc24ed>>

  8. David Platten reporter

    Hmm. SQLite and PostgreSQL sort the study names in the opposite order to one another. Swapped them so that it works OK with SQLite; need to change how I do the test so that it is database-agnostic. References issue #686

    → <<cset 2c806e965fdb>>

  9. David Platten reporter

    The chart options include the ability to state how you want the chart data ordered, so I'd like to keep the ordering in. However, this may be creating a rod for my own back. New commit coming up.

  10. David Platten reporter

    Added check for SQLite database to help with data order; assumes all other databases will sort strings in the same way that my PostgreSQL does; may be more sensible to bin the idea of worrying about this and just use Counter, as suggested by Ed. References issue #686

    → <<cset 1dc53e0f3333>>

  11. David Platten reporter

    These tests now work on my PostgreSQL install and on the SQLite system used by the automatic on-line tests.

  12. David Platten reporter

    Plumbing dict option into the view. Correcting an error with the CT num events charts that was preventing some from being displayed or calculated. Refs issue #477 and #686

    → <<cset 8d1ca21edaa6>>

  13. David Platten reporter

    Added requested procedure tests. These are not really very good as the included DICOM data has blank requested procedure names... Refs issue #686

    → <<cset 319491ab8fa7>>

  14. Daniel Wyatt

    Refs issue #686 - Included study frequency tests. Also included mean,median, boxplot and histogram tests for number of events. Yet to add plotseriespersystem repeats Also ran black for formatting

    → <<cset 04c728df1a14>>

  15. Log in to comment