fix age to start at 0 on start date of cycle instead of 1
This commit is contained in:
1 parent
3411ed4391
commit
54eb277c16
7 files changed
+33
-10
No files matched your search
@@ -128,6 +128,30 @@ class FarmAPITests(TestCase):
|
||||
self.assertEqual(Flock.objects.filter(kandang=self.kandang).count(), 1)
|
||||
self.assertEqual(flock.kandang_id, self.kandang.pk)
|
||||
|
||||
def test_current_day_is_zero_based_from_start_date(self):
|
||||
start = date(2026, 9, 2)
|
||||
cycle = Cycle.objects.create(
|
||||
kandang=self.kandang,
|
||||
total_days=35,
|
||||
start_date=start,
|
||||
end_date=start + timedelta(days=34),
|
||||
doc_in_weight=40,
|
||||
doc_in_count=9000,
|
||||
status=Cycle.STATUS_ACTIVE,
|
||||
)
|
||||
|
||||
with patch(
|
||||
"apps.operations.services.visibility.visible_through_date",
|
||||
return_value=start,
|
||||
):
|
||||
self.assertEqual(cycle.current_day, 0)
|
||||
|
||||
with patch(
|
||||
"apps.operations.services.visibility.visible_through_date",
|
||||
return_value=start + timedelta(days=1),
|
||||
):
|
||||
self.assertEqual(cycle.current_day, 1)
|
||||
|
||||
def test_list_flocks_by_kandang(self):
|
||||
self.client.force_authenticate(self.user)
|
||||
Flock.objects.create(flock_name="Lantai 1", kandang=self.kandang)
|
||||
|
||||
Reference in new issue
Block a user