Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Nov 9, 2023
1 parent 14f340e commit 5c0c371
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"plone.app.contenttypes",
"plone.app.robotframework[debug]",
"collective.MockMailHost",
"freezegun",
],
"app_io": [
"bravado",
Expand Down
17 changes: 14 additions & 3 deletions src/redturtle/prenotazioni/tests/test_week_table_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import unittest
from datetime import date
from freezegun import freeze_time

from plone import api
from plone.app.testing import (
Expand All @@ -19,7 +20,7 @@
)


class TestContextState(unittest.TestCase):
class TestWeekTableOverridesContextState(unittest.TestCase):
layer = REDTURTLE_PRENOTAZIONI_FUNCTIONAL_TESTING

def setUp(self):
Expand Down Expand Up @@ -93,6 +94,7 @@ def test_if_day_is_in_overrides_use_override_week_table(self):
json.loads(self.folder_prenotazioni.week_table_overrides)[0]["week_table"],
)

@freeze_time("2023-05-14")
def test_override_between_year(self):
self.folder_prenotazioni.week_table_overrides = json.dumps(
[
Expand All @@ -114,18 +116,27 @@ def test_override_between_year(self):
]
)
now = date.today()

# if in range, return table overrides
self.assertEqual(
self.view.get_week_table(date(now.year, 12, 25)),
json.loads(self.folder_prenotazioni.week_table_overrides)[0]["week_table"],
)

# if in range and next year, return table overrides
self.assertEqual(
self.view.get_week_table(date(now.year + 1, 1, 25)),
json.loads(self.folder_prenotazioni.week_table_overrides)[0]["week_table"],
)

# if out of range, return base table
self.assertEqual(
self.view.get_week_table(date(now.year, 5, 10)),
self.view.get_week_table(date(now.year, 10, 10)),
self.folder_prenotazioni.week_table,
)


class TestApiValidateDataOnPost(unittest.TestCase):
class TestWeekTableOverridesApiValidateDataOnPost(unittest.TestCase):
layer = REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING

def setUp(self):
Expand Down

0 comments on commit 5c0c371

Please sign in to comment.