def test_find_max_credits_of_partims(self): self.partim_1 = LearningUnitYearFactory(academic_year=self.academic_year, learning_container_year=self.learning_unit_year.learning_container_year, subtype=learning_unit_year_subtypes.PARTIM, credits=15) self.partim_2 = LearningUnitYearFactory(academic_year=self.academic_year, learning_container_year=self.learning_unit_year.learning_container_year, subtype=learning_unit_year_subtypes.PARTIM, credits=20) max_credits = find_max_credits_of_related_partims(self.learning_unit_year) self.assertEqual(max_credits, 20)
def _set_min_credits(self, instance): min_credits = find_max_credits_of_related_partims(instance) if min_credits is not None: self.fields["credits"].min_value = min_credits self.fields['credits'].validators.append(MinStrictlyValueValidator(min_credits))
def test_find_max_credits_of_partims_when_no_partims_related(self): max_credits = find_max_credits_of_related_partims(self.learning_unit_year) self.assertEqual(max_credits, None)