-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 [Fix] intervention date filter and add intervention years filter
- Loading branch information
Showing
7 changed files
with
107 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.test import TestCase | ||
from geotrek.maintenance.models import Intervention | ||
from geotrek.maintenance.tests.factories import InterventionFactory | ||
|
||
|
||
class InterventionManagerTest(TestCase): | ||
|
||
def test_intervention_with_not_end_date(self): | ||
InterventionFactory(name="test1", begin_date="2020-06-03") | ||
InterventionFactory(name="test2", begin_date="2022-06-03") | ||
self.assertEqual(Intervention.objects.year_choices(), [(2020, 2020), (2022, 2022)]) | ||
|
||
def test_intervention_with_end_date(self): | ||
InterventionFactory(name="test1", begin_date="2018-06-03", end_date="2020-06-03") | ||
InterventionFactory(name="test2", begin_date="2022-06-03", end_date="2024-06-03") | ||
self.assertEqual(Intervention.objects.year_choices(), [(2018, 2018), (2019, 2019), (2020, 2020), (2022, 2022), (2023, 2023), (2024, 2024)]) | ||
|
||
def test_intervention_with_one_have_end_date(self): | ||
InterventionFactory(name="test1", begin_date="2020-06-03") | ||
InterventionFactory(name="test2", begin_date="2022-06-03", end_date="2024-06-03") | ||
self.assertEqual(Intervention.objects.year_choices(), [(2020, 2020), (2022, 2022), (2023, 2023), (2024, 2024)]) | ||
|
||
def test_intervention_return_distinct_year(self): | ||
InterventionFactory(name="test1", begin_date="2020-06-03") | ||
InterventionFactory(name="test2", begin_date="2018-06-03", end_date="2024-06-03") | ||
self.assertEqual(Intervention.objects.year_choices(), [(2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)]) |