mirror of
https://github.com/wger-project/wger.git
synced 2026-02-18 00:17:51 +01:00
Remove null constraint from the order field in SlotEntry and add some tests
This commit is contained in:
@@ -140,7 +140,6 @@ class SlotEntry(models.Model):
|
||||
|
||||
order = models.PositiveIntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -58,6 +58,24 @@ class SlotEntryTestCase(WgerTestCase):
|
||||
)
|
||||
self.slot_entry.save()
|
||||
|
||||
def test_auto_add_order(self):
|
||||
"""
|
||||
Test that the order is automatically added if not provided
|
||||
"""
|
||||
slot_entry_2 = SlotEntry(slot_id=1, exercise_id=2, order=None)
|
||||
slot_entry_2.save()
|
||||
|
||||
slot_entry_3 = SlotEntry(slot_id=1, exercise_id=3, order=7)
|
||||
slot_entry_3.save()
|
||||
|
||||
slot_entry_4 = SlotEntry(slot_id=1, exercise_id=3)
|
||||
slot_entry_4.save()
|
||||
|
||||
self.assertEqual(self.slot_entry.order, 1)
|
||||
self.assertEqual(slot_entry_2.order, 2)
|
||||
self.assertEqual(slot_entry_3.order, 7)
|
||||
self.assertEqual(slot_entry_4.order, 8)
|
||||
|
||||
def test_weight_config(self):
|
||||
"""
|
||||
Test that the weight is correctly calculated for each step / iteration
|
||||
|
||||
Reference in New Issue
Block a user