-
Notifications
You must be signed in to change notification settings - Fork 22
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
Resignation tests kerstens fork #569
Resignation tests kerstens fork #569
Conversation
…dability First attempt ;) for getting the shift calendar more readable.
…or-logs Collapsing also for the log view
First suggestion for ShiftAttendance entry in contributing
…fixes Little translations corrections (hint from Vicky) conc. automated mails.
Translations fixes
Hi @Theophile-Madet, I'm sorry to disturb you. But I'm completely stuck with the tests, which you preformulated. I don't get the changed object in the updateview and deleteview. The The form and service tests should be fine now. They are all green (puh ;) ). |
So, the problem is that I think it's because Lines 302 to 304 in a19c55d
But pay_out_day is not a field of MembershipResignationForm , so the lines do nothing. The form will look in cleaned_data only for the fields that are part of the form. The solution would be to do that change in the view rather than the form.
There is a similar test for the create view:
Let me know if that helps, or if you meant another problem. Also, should I already look at the other tests? I only checked |
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.
Getting closer, I left more comments.
) | ||
self.assertEqual(share.end_date, resignation.cancellation_date) | ||
|
||
def test_update_shifts_shiftsAndShiftAttendance_cancelled(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.
This test fails on my machine. The shift from shift = ShiftFactory.create()
is generated in the past, so it doesn't get affected by update_shifts
. You can fix it by setting the start_time
of the shift in the future relative to self.NOW
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.
This is not fixed.
For #569 (comment) |
I must have mixed up the UpdateLogEntry with the other types of log entries. It's true that UdpateLogEntry don't have
Since this is an |
Salut @Theophile-Madet, I made several new fixes, renaming, separating test in more funcs .... . The only thing I don't get done is the case with |
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 re-opened 2 conversations that were closed but the problem was not fixed, and left a few extra comments. I find less and less comments to write, so that means we're getting closer and closer.
About test_membershipResignationCreateView_default_changesApplied
, I think I found what was confusing you: the order of the test function parameters are reversed (the two mock_...
). I think the test should look like this:
@patch.object(MembershipResignationService, "delete_shareowner_membershippauses")
@patch.object(
MembershipResignationService, "update_shifts_and_shares_and_pay_out_day"
)
def test_membershipResignationCreateView_default_changesApplied(
self,
mock_update_shifts_and_shares_and_pay_out_day: Mock,
mock_delete_shareowner_membershippauses: Mock,
):
resignation, actor = self.create_default_resignation()
self.assertEqual(1, MembershipResignation.objects.count())
mock_delete_shareowner_membershippauses.assert_called_once_with(resignation)
mock_update_shifts_and_shares_and_pay_out_day.assert_called_once_with(
resignation=resignation
)
@@ -58,9 +62,10 @@ def update_shifts(tapir_user: TapirUser, resignation: MembershipResignation): | |||
) | |||
|
|||
for attendance_template in ShiftAttendanceTemplate.objects.filter( | |||
user=tapir_user | |||
user=tapir_user, | |||
slot_template__shift_template__start_date__gte=start_date, |
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.
We shouldn't filter relative to the start date of the shift template: if a member registers to a shift template that started for example on 15/06/23, then resigns on the 15/11/24, we still want to cancel that attendance template.
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.
What did you mean then by this: #569 (comment)?
I didn't get quiet well yet how the shift-system works in total.
) | ||
self.assertEqual(share.end_date, resignation.cancellation_date) | ||
|
||
def test_update_shifts_shiftsAndShiftAttendance_cancelled(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.
This is not fixed.
ShiftAttendance.State.CANCELLED, | ||
) | ||
|
||
def test_updateShifts_shiftsBeforeResignation_notCancelled(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.
It looks like there is confusion about the start_date
of ShiftTemplate
: it's the date from which the ShiftTemplate
should start generating shifts. So it's not relevant to resignations: no matter what the ShiftTemplate.start_date
is, if the resigning member is registered to ShiftTemplate
, they should get unregistered from that ShiftTemplate
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 thought to achieve this topic (#569 (comment)), with the start_date
of the ShiftTemplate
. Is it more the Shift start_time
?
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.
Yes, the only time to check is the time of the Shift
: shifts that are before the resignation should not get affected.
The start_date
of the ShiftTemplate
is irrelevant.
Nothing helps, if I do your version, I get the error:
If I do it reverse:
I get the same error:
|
The first logs that you copy show that you are not running my version of the test. We can see that because the logs says The second logs you copied also do not correspond to the code snippet you copied. We can see that because the code say To help you I need the code and the logs that come with that code. If they don't fit nothing makes sense. |
Hi @Theophile-Madet, I got the |
@@ -42,7 +44,6 @@ def update_shifts_and_shares_and_pay_out_day(resignation: MembershipResignation) | |||
for _ in shares | |||
] | |||
ShareOwnership.objects.bulk_create(shares_to_create) | |||
shares.update(end_date=resignation.cancellation_date) |
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.
We don't need here a cancellation date for the transferred shares, right? They begin from scratch.
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.
That's true, transfered shares should not have an end date.
@@ -87,8 +89,8 @@ def test_updateShiftsAndSharesAndPayOutDay_SharesAndPayOutDayForResignationTypeT | |||
).count(), | |||
shares_after_update.count(), | |||
) | |||
for share in shares_after_update.all(): | |||
self.assertEqual(share.end_date, resignation.cancellation_date) | |||
# for share in shares_after_update.all(): |
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.
Therefore we don't need this test?!
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.
"This test" is the entire test_updateShiftsAndSharesAndPayOutDay_SharesAndPayOutDayForResignationTypeTransfer_transferredAndSet
function, that we do need.
Instead of removing self.assertEqual(share.end_date, resignation.cancellation_date)
, let's replace it with self.assertEqual(share.end_date, None)
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.
- About
assert_called_once_with
: the assert has to be the same as the logic code. If in the service the function is called with the parameter name, thenassert_called_once_with
has to be with the parameter name too. If the service calls the function without the parameter name, thenassert_called_once_with
has to be called without parameter name either. test_updateShifts_shiftsAndShiftAttendance_cancelled
still needs fixing: thestart_time
of theShift
must be set explicitely to make sure that the random generation doesn't put the shift in the past. See this comment- I answered your comment about the shift start time.
@@ -42,7 +44,6 @@ def update_shifts_and_shares_and_pay_out_day(resignation: MembershipResignation) | |||
for _ in shares | |||
] | |||
ShareOwnership.objects.bulk_create(shares_to_create) | |||
shares.update(end_date=resignation.cancellation_date) |
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.
That's true, transfered shares should not have an end date.
@@ -87,8 +89,8 @@ def test_updateShiftsAndSharesAndPayOutDay_SharesAndPayOutDayForResignationTypeT | |||
).count(), | |||
shares_after_update.count(), | |||
) | |||
for share in shares_after_update.all(): | |||
self.assertEqual(share.end_date, resignation.cancellation_date) | |||
# for share in shares_after_update.all(): |
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.
"This test" is the entire test_updateShiftsAndSharesAndPayOutDay_SharesAndPayOutDayForResignationTypeTransfer_transferredAndSet
function, that we do need.
Instead of removing self.assertEqual(share.end_date, resignation.cancellation_date)
, let's replace it with self.assertEqual(share.end_date, None)
MembershipResignationService.update_shifts_and_shares_and_pay_out_day( | ||
resignation_one | ||
) | ||
MembershipResignationService.update_shifts_and_shares_and_pay_out_day( | ||
resignation_two | ||
) | ||
share_owner.refresh_from_db() | ||
ic(share_owner.num_shares()) |
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.
This can be removed
ShiftAttendance.State.CANCELLED, | ||
) | ||
|
||
def test_updateShifts_shiftsBeforeResignation_notCancelled(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.
Yes, the only time to check is the time of the Shift
: shifts that are before the resignation should not get affected.
The start_date
of the ShiftTemplate
is irrelevant.
Hi @Theophile-Madet, accomplished #569 (comment)
I get the error:
And if I write it without parameter
and also If I write |
I customized the Shift- |
You keep getting the same error with The current order is @patch.object(MembershipResignationService, "delete_shareowner_membershippauses")
@patch.object(
MembershipResignationService, "update_shifts_and_shares_and_pay_out_day"
)
def test_membershipResignationCreateView_default_changesApplied(
self,
mock_delete_shareowner_membershippauses: Mock,
mock_update_shifts_and_shares_and_pay_out_day: Mock,
): The correct order is @patch.object(MembershipResignationService, "delete_shareowner_membershippauses")
@patch.object(
MembershipResignationService, "update_shifts_and_shares_and_pay_out_day"
)
def test_membershipResignationCreateView_default_changesApplied(
self,
mock_update_shifts_and_shares_and_pay_out_day: Mock,
mock_delete_shareowner_membershippauses: Mock,
): Because the order is wrong, the variable called |
|
Hi @Theophile-Madet, please believe me, that I was not intended to be disrespectful to you! It was just that I hanging in a stuck-line. I still don't understand, why |
tapir/tapir/coop/views/membership_resignation.py Lines 255 to 257 in ef86f52
tapir/tapir/coop/views/membership_resignation.py Lines 258 to 260 in ef86f52
That's what I was explaining here:
|
I'm very sorry I looked at the wrong place, I really had a "Brett vor dem Kopf". I looked all the time at |
075c872
into
SuperCoopBerlin:resignation_tests
* WIP resignation tests * Added base test for the membership resignation create view. * WIP tests. * Membership resignation edit view tests. * Membership resignation detail and delete views tests. * 1st try for TestMembershipResignationForm. * Resignation tests kerstens fork (#569) * First suggestion for ShiftAttendance entry in contributing * First attempt ;) for getting the shift calendar more readable. * Collasping also for the log view * Fixed hopefully all changes requests. * Fixed text for ShiftAttendance. * Fixed collapsing list. * Deleted all "filter-button" classes. * Set seletc2-width to 100%. * Last fixes with flexbox ;) * Align title to center with flexbox. * Translations corrections (hint from Vicky). * Fixes in opening hours. * Missing po-file * Restored 24h time * Sorry for fuzzied po-file. Removed. * Translations fixes * Update translations. * Search for Nonetype im form test. * test_membershipResignationForm_is_valid & test_validate_shareOwner_function * Form tests done. * Form tests work, but view tests still fails. * Updateview-tests ready * Changed service-function update_shifts_and_shares_and_pay_out_day in all placed * Several fixes for all resignation-tests. * More fixes for resignation-tests. * Even more fixes for resignation-tests 1.0 * Even more fixes for resignation-tests 1.1 * Even more fixes for resignation-tests 1.2 * Even more fixes for resignation-tests 1.3 * Even more fixes for resignation-tests 1.4 * Even more fixes for resignation-tests 1.5 * Even more fixes for resignation-tests 1.6 --------- Co-authored-by: Kersten Weise <[email protected]> Co-authored-by: Kersten Weise <[email protected]> * Fixed migration conflict after merge, Improved view names, Cleanup in test_create_view.py Removed test_create_membershipresignation.py that contains only duplicates of test_create_view.py * Cleanup in test_delete_view.py, More view name updates. * Cleanup in test_edit_view.py * Cleanup in test_form.py * Cleanup in test_service.py * Post-rename fix. * Switched ShareOwnership.transferred_from to OneToOneField to make sure a share can't be transferred twice. * UI improvements around resignation cancellations. * Translation file update. --------- Co-authored-by: Kersten Weise <[email protected]> Co-authored-by: Kersten Weise <[email protected]>
No description provided.