Skip to content

Conversation

@RoordinkFrank
Copy link
Contributor

@RoordinkFrank RoordinkFrank commented Oct 15, 2025

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.


image

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.

@RoordinkFrank RoordinkFrank changed the base branch from develop to Feat/pre-assesment_get_revisions October 15, 2025 12:15
…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)
Copy link
Contributor Author

@RoordinkFrank RoordinkFrank Oct 16, 2025

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.",
)
Copy link
Contributor Author

@RoordinkFrank RoordinkFrank Oct 16, 2025

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):
Copy link
Contributor Author

@RoordinkFrank RoordinkFrank Oct 16, 2025

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()
Copy link
Contributor Author

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.

@RoordinkFrank RoordinkFrank marked this pull request as ready for review October 17, 2025 10:15
Copy link
Contributor

@miggol miggol left a 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:

  1. Added fixtures rather than explicit Proposal/user creation.
  2. Merger of Proposal and Review base classes
  3. Other changes/refactoring in SetUp, such as new helper methods
  4. New tests added
  5. Fixes for auto review test and test_long_route (?)
  6. 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_revisions which 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

Comment on lines +60 to +67
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"
Copy link
Contributor

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()
Copy link
Contributor

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.

Comment on lines +78 to +83
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()
Copy link
Contributor

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.

@RoordinkFrank
Copy link
Contributor Author

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:

1. Added fixtures rather than explicit Proposal/user creation.

2. Merger of Proposal and Review base classes

3. Other changes/refactoring in SetUp, such as new helper methods

4. New tests added

5. Fixes for auto review test and test_long_route (?)

6. 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_revisions` which 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

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.

@RoordinkFrank RoordinkFrank changed the base branch from Feat/pre-assesment_get_revisions to feat/test_cleanup October 28, 2025 10:48
@RoordinkFrank RoordinkFrank changed the base branch from feat/test_cleanup to Feat/pre-assesment_get_revisions October 28, 2025 10:49
@RoordinkFrank RoordinkFrank changed the base branch from Feat/pre-assesment_get_revisions to feat/pre-assesment_tests November 12, 2025 15:33
@RoordinkFrank RoordinkFrank marked this pull request as draft November 12, 2025 16:02
Base automatically changed from feat/pre-assesment_tests to Feat/pre-assesment_get_revisions November 21, 2025 12:41
Base automatically changed from Feat/pre-assesment_get_revisions to develop December 16, 2025 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants