Best Python code snippet using Kiwi_python
models.py
Source: models.py
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 )...
apps.py
Source: apps.py
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)...
Check out the latest blogs from LambdaTest on this topic:
Howdy testers! If you’re reading this article I suggest you keep a diary & a pen handy because we’ve added numerous exciting features to our cross browser testing cloud and I am about to share them with you right away!
Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
Lack of training is something that creates a major roadblock for a tester. Often, testers working in an organization are all of a sudden forced to learn a new framework or an automation tool whenever a new project demands it. You may be overwhelmed on how to learn test automation, where to start from and how to master test automation for web applications, and mobile applications on a new technology so soon.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!