How to use pre_save_clean method in Kiwi

Best Python code snippet using Kiwi_python

models.py

Source:models.py Github

copy

Full Screen

1"""2Aristotle MDR 11179 Link and Relationship models3================================================4These are based on the Link and Relation definitions in ISO/IEC 11179 Part 3 - 9.1.2.4 - 9.1.2.55"""6from django.db import models7from django.db.models.signals import pre_save8from django.core.exceptions import ValidationError9from django.core.validators import MinValueValidator10from django.utils.translation import ugettext_lazy as _11from django.utils.encoding import python_2_unicode_compatible # Python 212from model_utils.models import TimeStampedModel13from aristotle_mdr import models as MDR14from aristotle_mdr.signals import pre_save_clean15class Relation(MDR.concept): # 9.1.2.416 """17 """18 arity = models.PositiveIntegerField( # 9.1.2.4.3.119 help_text=_('number of elements in the relation'),20 validators=[MinValueValidator(2)]21 )22@python_2_unicode_compatible # Python 223class RelationRole(MDR.aristotleComponent): # 9.1.2.524 name = models.TextField(25 help_text=_("The primary name used for human identification purposes.")26 )27 definition = models.TextField(28 _('definition'),29 help_text=_("Representation of a concept by a descriptive statement "30 "which serves to differentiate it from related concepts. (3.2.39)")31 )32 multiplicity = models.PositiveIntegerField( # 9.1.2.5.3.133 # a.k.a the number of times it can appear in a link :(34 help_text=_(35 'number of links which must (logically) be members of the source '36 'relation of this role, differing only by an end with this role as '37 'an end_role.'38 ),39 null=True,40 blank=True,41 )42 ordinal = models.PositiveIntegerField( # 9.1.2.5.3.243 help_text=_(44 'order of the relation role among other relation roles in the relation.'45 )46 )47 relation = models.ForeignKey(Relation)48 @property49 def parentItem(self):50 return self.relation51 def __str__(self):52 return "{0.name}".format(self)53class Link(TimeStampedModel):54 """55 Link is a class each instance of which models a link (3.2.69).56 A link is a member of a relation (3.2.119) (not an instance of a relation).57 In relational database parlance, a link would be a tuple (row) in a relation (table).58 Link is a subclass of Assertion (9.1.2.3), and as such is included in one or more59 Concept_Systems (9.1.2.2) through the assertion_inclusion (9.1.3.5) association.60 """61 relation = models.ForeignKey(Relation)62 def concepts(self):63 return MDR._concept.objects.filter(linkend__link=self).all().distinct()64 def add_link_end(self, role, concept):65 return LinkEnd.objects.create(link=self, role=role, concept=concept)66class LinkEnd(TimeStampedModel): # 9.1.2.767 link = models.ForeignKey(Link)68 role = models.ForeignKey(RelationRole)69 concept = models.ForeignKey(MDR._concept)70 def clean(self):71 if self.role.relation != self.link.relation:72 raise ValidationError(73 _('A link ends role relation must be from the relation itself')74 )...

Full Screen

Full Screen

apps.py

Source:apps.py Github

copy

Full Screen

1from django.apps import AppConfig as DjangoAppConfig2class AppConfig(DjangoAppConfig):3 name = 'tcms.testplans'4 def ready(self):5 from django.db.models.signals import post_save, pre_save6 from .models import TestPlan7 from tcms import signals8 pre_save.connect(signals.pre_save_clean, TestPlan)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful