def test_property_is_list(self): restrictions = Restrictions() self.assertFalse(restrictions.is_list) restrictions.max_occurs = 1 self.assertFalse(restrictions.is_list) restrictions.max_occurs = 2 self.assertTrue(restrictions.is_list)
def sanitize_restrictions(cls, restrictions: Restrictions): min_occurs = restrictions.min_occurs or 0 max_occurs = restrictions.max_occurs or 0 if min_occurs == 0 and max_occurs <= 1: restrictions.required = None restrictions.min_occurs = None restrictions.max_occurs = None if min_occurs == 1 and max_occurs == 1: restrictions.required = True restrictions.min_occurs = None restrictions.max_occurs = None elif restrictions.max_occurs and max_occurs > 1: restrictions.min_occurs = min_occurs restrictions.required = None