Add integration tests for all the views and fix broken HTML. #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.