Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add integration tests for all the views and fix broken HTML. #29

Merged
merged 7 commits into from
Jan 5, 2024

Conversation

njohner
Copy link
Contributor

@njohner njohner commented Jan 4, 2024

With this PR we add tests for the django views of the webapp. We use the django testing framework for this, notably its client, which allows us to make requests and test that the views are rendered properly.

As a testing fixture I chose to use the actual DB generated by the annotation pipeline tests. I did not add that DB to the repository, but rather can generate it anew by running the pipeline tests. This allows us to test with real data, created from the current version of the software and not some outdated database. Of course this could render the tests sensitive to changes in the reference databases or in our pipelines or tools used therein. I don't think that this should be too much of a problem right now, as the tests are very generic.

We currently mainly test 2 things:

  • That every view returns a 200 OK
  • That every view generates valid HTML

It turned out that almost all the views would return invalid HTML, so I fixed all the templates. There is just one template (fam.html) where I also changed the indentation because it was so complex and messy that I couldn't figure out what was wrong otherwise. Sorry if the diff for that template is hard to read.

I also found that some urlpatterns were clearly unused as they led to passing the wrong number of arguments to the corresponding views, so I removed them.

Moreover some views are broken and throw errors. I did not fix them yet. This is out of scope for this PR and they are all views that I don't even know how to access in the web-application.

Finally I've added a few more thorough tests for a couple of views, notably posting data to some of the forms to verify that a plot would then be rendered. In the long run we should have such tests for all views, but this is out of scope here. The provided tests serve as POC that the library is appropriate for our needs and as templates writing tests for the other views in the future.

@njohner njohner changed the base branch from master to nj/fixes January 4, 2024 16:05
@njohner njohner requested a review from tpillone January 4, 2024 16:05
Some urlpatterns corresponded to calling views with an unsupported
number of arguments. We remove those patterns.
Base automatically changed from nj/fixes to master January 5, 2024 08:09
@njohner njohner merged commit a550458 into master Jan 5, 2024
@njohner njohner deleted the nj/test_views branch January 5, 2024 08:10
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant