Skip to content

Commit

Permalink
[IMP] base_recurrence: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasProgrammer committed Aug 2, 2023
1 parent 551df65 commit f690148
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
4 changes: 2 additions & 2 deletions base_recurrence/models/recurrence_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def _get_next_recurrency_date(self):

def _update_recurrency_date(self):
"""
Update the last recurrency date from the next recurrency date,
then compute the new next recurrency date.
Update the last recurrency date from the next recurrency date,
then compute the new next recurrency date.
"""
for record in self:
record.update(
Expand Down
36 changes: 24 additions & 12 deletions base_recurrence/tests/test_recurrence.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def test_recurrence_now(self):
record._set_next_recurrency_date(from_now=True)

self.assertEqual(
fields.Datetime.to_datetime("2022-07-18"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-07-18"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -56,7 +57,8 @@ def test_recurrence(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2022-07-18"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-07-18"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -76,7 +78,8 @@ def test_recurrence_daily(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2022-07-12"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-07-12"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -96,7 +99,8 @@ def test_recurrence_monthly(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2022-08-11"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-08-11"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -116,7 +120,8 @@ def test_recurrence_monthlylastday(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2022-08-31"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-08-31"),
record.next_recurrency_date,
)

@freeze_time("2022-01-11")
Expand All @@ -136,7 +141,8 @@ def test_recurrence_monthlylastday_february(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2022-02-28"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-02-28"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -156,7 +162,8 @@ def test_recurrence_quarterly(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2022-10-01"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-10-01"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -176,7 +183,8 @@ def test_recurrence_semsterly(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2023-01-01"), record.next_recurrency_date,
fields.Datetime.to_datetime("2023-01-01"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -196,7 +204,8 @@ def test_recurrence_yearly(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2023-07-11"), record.next_recurrency_date,
fields.Datetime.to_datetime("2023-07-11"),
record.next_recurrency_date,
)

@freeze_time("2022-07-11")
Expand All @@ -216,13 +225,16 @@ def test_update_recurrence_yearly(self):
record._set_next_recurrency_date()

self.assertEqual(
fields.Datetime.to_datetime("2022-07-10"), record.next_recurrency_date,
fields.Datetime.to_datetime("2022-07-10"),
record.next_recurrency_date,
)

record._update_recurrency_date()
self.assertEqual(
fields.Datetime.to_datetime("2023-07-10"), record.next_recurrency_date,
fields.Datetime.to_datetime("2023-07-10"),
record.next_recurrency_date,
)
self.assertEqual(
fields.Datetime.to_datetime("2022-07-10"), record.last_recurrency_date,
fields.Datetime.to_datetime("2022-07-10"),
record.last_recurrency_date,
)
1 change: 1 addition & 0 deletions setup/base_recurrence/odoo/addons/base_recurrence
6 changes: 6 additions & 0 deletions setup/base_recurrence/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit f690148

Please sign in to comment.