Skip to content

[18.0][FIX] hr_holidays_natural_period: Create no_validation leave - #254

Open
SirPyTech wants to merge 1 commit into
OCA:18.0from
PyTech-SRL:18.0-fix-hr_holidays_natural_period-no_admin
Open

[18.0][FIX] hr_holidays_natural_period: Create no_validation leave#254
SirPyTech wants to merge 1 commit into
OCA:18.0from
PyTech-SRL:18.0-fix-hr_holidays_natural_period-no_admin

Conversation

@SirPyTech

@SirPyTech SirPyTech commented May 13, 2026

Copy link
Copy Markdown

Forward port of #248.
There is no change to the module's code because apparently this version is not affected by the same issue that was present in 16.0.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @victoralmau,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added mod:hr_holidays_natural_period Module hr_holidays_natural_period series:18.0 labels May 13, 2026
@SirPyTech
SirPyTech marked this pull request as ready for review May 13, 2026 08:01

@quirino95 quirino95 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and functional review: LGTM!

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@pedrobaeza pedrobaeza changed the title [FIX] hr_holidays_natural_period: Create no_validation leave [18.0][FIX] hr_holidays_natural_period: Create no_validation leave Jun 5, 2026
@pedrobaeza pedrobaeza added this to the 18.0 milestone Jun 5, 2026
self.assertEqual(leave_type.leave_validation_type, "no_validation")
for manager_group in manager_groups:
self.assertNotIn(manager_group, self.env.user.groups_id)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add empty lines inside a method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for having a look!
Sometimes I use blank lines in a method to keep logical sections of the method separated, this kind of usage is even mentioned in PEP8 https://peps.python.org/pep-0008/#blank-lines:

Use blank lines in functions, sparingly, to indicate logical sections.

Is there any specific reason why they should be removed? If that's just an opinion-based style decision I'd rather keep them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because:

  • sparingly means infrequent, not the usual thing to do.
  • keep the current style of the module, which no lines inside the method.
  • What is for you a logical section? It can be different from me, and adding a blank line doesn't enforce what that "logical section" does. If you really want to have logical sections, add a line with a comment explaining what the next logical section is.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that https://github.com/OCA/hr-holidays/pull/254/changes#r3361035074 triggered more heated comments on the rest of the code 🔥 sorry to have upset you.

Just to give you more context, this test method follows the AAA testing pattern (see for instance https://dev.to/coderjay06/the-three-a-s-of-unit-testing-b22) and most of the times I find it useful to give a clear structure to test methods:

Arrange the state of the data to set it up for testing.

Act on the data through some method that performs an action.

Assert that the result from acting on that data is what we expect it to be.

The 3 logical sections in this method follow this structure.

# Act
leave = self._create_hr_leave(leave_type, "3000-01-01", "3000-01-01")

# Assert

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is redundant, as the Python code already infers that you assert in the next line.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clarifies that we are in the third step of the AAA testing pattern (see for instance https://dev.to/coderjay06/the-three-a-s-of-unit-testing-b22).

for manager_group in manager_groups:
self.assertNotIn(manager_group, self.env.user.groups_id)

# Act

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of this comment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clarifies that we are in the second step of the AAA testing pattern (see for instance https://dev.to/coderjay06/the-three-a-s-of-unit-testing-b22).

@SirPyTech SirPyTech left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently we have different opinions on using blank lines, but that happens, I hope this won't block the PR 🤞.

self.assertEqual(leave_type.leave_validation_type, "no_validation")
for manager_group in manager_groups:
self.assertNotIn(manager_group, self.env.user.groups_id)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that https://github.com/OCA/hr-holidays/pull/254/changes#r3361035074 triggered more heated comments on the rest of the code 🔥 sorry to have upset you.

Just to give you more context, this test method follows the AAA testing pattern (see for instance https://dev.to/coderjay06/the-three-a-s-of-unit-testing-b22) and most of the times I find it useful to give a clear structure to test methods:

Arrange the state of the data to set it up for testing.

Act on the data through some method that performs an action.

Assert that the result from acting on that data is what we expect it to be.

The 3 logical sections in this method follow this structure.

for manager_group in manager_groups:
self.assertNotIn(manager_group, self.env.user.groups_id)

# Act

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clarifies that we are in the second step of the AAA testing pattern (see for instance https://dev.to/coderjay06/the-three-a-s-of-unit-testing-b22).

# Act
leave = self._create_hr_leave(leave_type, "3000-01-01", "3000-01-01")

# Assert

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clarifies that we are in the third step of the AAA testing pattern (see for instance https://dev.to/coderjay06/the-three-a-s-of-unit-testing-b22).

@pedrobaeza

Copy link
Copy Markdown
Member

My thumb rule is simple: less is more. To not have to do more vertical scrolling. All of this pattern thing is very good, but that's a methodology, not something that should be literally ported putting that comments. You don't even put # AAA testing pattern: Assert that at least will clarify more. You put # Assert. About that methodology, the arrange phase can't be always be done at the beginning, but let's not start that debate.

The most important thing here is that this not a new module, just an added test, where the rest of the tests are not done that way, so please respect the current general style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants