-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/faster tests #1007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feat/faster tests #1007
Conversation
…ound other preassessment tests.
… easier this way.
…tion to remake pre-assessement tests in the same way proposal_submisison_tests works.
…out if they are supposed to go wrong or not. Fused testdata from test and proposal_submission_tests.py
…hem. added study fixture, not yet working added messages to assert statement to slowly get more understanding where it goes wrong.
…w, var is no longer needed as naming fixtures for studies temp commented out. Did not get them to work properly
|
|
||
| def startReview(self): | ||
| # super().startReview() | ||
| self.review = start_review(self.pre_assessment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setUp review -> setUp actual tests -> setUp pre assessment is the order that triggers and it has to remain this way. Yet I do want review -> pre assessment -> actual tests which is imposible in current setup so i have to override startReview here.
Possible solution is the same as in one of my previous comments about proposal inheriting the same was as preAssessment is doing now.
| self.assertEqual( | ||
| reasons[-1], | ||
| "De onderzoeker geeft aan dat er mogelijk kwesties zijn rondom de veiligheid van de deelnemers tijdens of na het onderzoek.", | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing self.study.proposal to self.proposal makes it possible to load studies with fixtures. Why this is needed I still do not know, but it works.
reviews/tests.py
Outdated
| self.setup_proposal() | ||
| super().setUp() | ||
|
|
||
| def setup_proposal(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate pdf removed here. It was not actually used and significantly slowed down tests as it was done for every test. If it is needed somewhere in the future I propose adding it locally.
… testcases. Autoreview can handle pre assesssment
| self.proposal.save() | ||
|
|
||
| def remove_study(self): | ||
| Study.objects.filter(proposal=f"{self.proposal.pk}").delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be needed in two tests.
miggol
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this PR is branched from a different PR, but once again this is a PR that addresses various tangentially related things without any issues or stated goals.
As far as I can tell the following distinct things are going on here:
- Added fixtures rather than explicit Proposal/user creation.
- Merger of Proposal and Review base classes
- Other changes/refactoring in SetUp, such as new helper methods
- New tests added
- Fixes for auto review test and test_long_route (?)
- Remove generate PDF
Don't get me wrong, I'm a big fan of the merger of the Proposal an Review testcases in particular. But this borders on impossible to review. For me to Approve this, it will have to be in smaller chunks.
- (1) and (2) should be separate PRs into develop
- (3) can be dropped for now
- (4) should be in this PR, because it adds a test for
Feat/pre-assessment_get_revisionswhich the branch will merge into. That is a good stated goal for this specific PR, stick to that. - If (5) contains fixes for bugs or failing tests, please describe them and make issues for them before fixing in a separate PR. If these fixes are absolutely required for merging (4), I guess they can be in this PR, but in that case please precisely describe what you're doing.
- (6) can also be dropped for now, but could be chucked together with (3) in a future PR
| self.proposal = Proposal.objects.get( | ||
| reference_number="24-009-01", title="Normal test proposal" | ||
| ) | ||
| self.pre_assessment = Proposal.objects.get( | ||
| reference_number="24-010-01", title="Preassessment test proposal" | ||
| ) | ||
| self.pre_approval = Proposal.objects.get( | ||
| reference_number="24-011-01", title="Preapproved test pdf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in passing, I must say I disagree with black on this one...
| self.proposal.save() | ||
|
|
||
| def remove_study(self): | ||
| Study.objects.filter(proposal=f"{self.proposal.pk}").delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does self.proposal.study_set.all().delete() not work? As written your version seems a bit omslachtig. Also it removes all studies so best to call it remove_studies() (plural)
I would also be down with removing this method entirely. Calling it doesn't even save a single line.
| def add_supervisor_to_proposal(self): | ||
| self.proposal.relation = Relation.objects.get( | ||
| description_nl="als AIO / promovendus verbonden" | ||
| ) | ||
| self.proposal.supervisor = self.supervisor | ||
| self.proposal.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that this method implicitly changes the relation. I would rather keep these steps explicit (and in the test) so that if those tests fail, it's easier to see.
After feedback that this pull request is to big I will try to split this up into different branches. This branch will not change but as other branches are slowly be merged into develop this one should become smaller. Up to date status is at the first comment of this pull request. |
branched from #1001
I noticed tests getting from 24s to 8s during pre-assessment as soon as test data transferred to fixtures. Those 8s are with the added pre-assessment tests.
After feedback that this pull request is to big I will try to split this up into different branches. This branch will not change but as other branches are slowly be merged into develop this one should become smaller.
Code with a different branch:
These branches are branched from each other from top to bottom. To merge test data this is needed.
To clarify, these helper methods are mostly methods that already did exist. Just moved up to parent classes. That or duplicate code refactored to a method.