How to use has_contains method in pyresttest

Best Python code snippet using pyresttest_python

decompose_graph.py

Source:decompose_graph.py Github

copy

Full Screen

1from core.himesis_utils import graph_to_dot2#from core.new_match_algo import NewHimesisMatcher3from profiler import *4try:5 from functools import lru_cache6except ImportError:7 print("Warning: Could not import lru_cache")8 def lru_cache(maxsize=32):9 def true_decorator(f):10 return f11 return true_decorator12#@do_cprofile13#@Profiler14#@lru_cache(maxsize=1024)15#@profile16def decompose_graph(graph, verbosity = 0, ignore_apply_dls = False, isolated_if_attached_backward = False, get_isolated_match_elements = False):17 #decompose graph into directLinks, backwardLinks, and isolated elements18 debug = False19 #debug = "Hlayer1rule10" in graph.name20 if debug:21 print("\nDecomposing graph: " + graph.name)22 #graph_to_dot(graph.name, graph)23 match_elements = []24 #isolated_match_elements = []25 apply_elements = []26 try:27 mms = graph.vs["mm__"]28 if mms[0].startswith("MT_pre__"):29 mms = [mm[8:] for mm in mms]30 except KeyError:31 mms = []32 # only get the match direct links33 if ignore_apply_dls:34 dls = set([i for i, mm in enumerate(mms) if mm == "directLink_S"])35 else:36 dls = set([i for i, mm in enumerate(mms) if mm in ["directLink_S", "directLink_T"]])37 bls = set([i for i, mm in enumerate(mms) if mm in ["trace_link", "backward_link"]])38 direct_links_dict = {n: [None, None] for n in dls}39 backward_links_dict = {n: [None, None] for n in bls}40 # direct_links_dict = {}41 # for n in dls:42 # direct_links_dict[n] = [None, None]43 #44 # backward_links_dict = {}45 # for n in bls:46 # backward_links_dict[n] = [None, None]47 has_contains = "match_contains" in mms48 for source, target in [e.tuple for e in graph.es]:49 #source, target = e.tuple50 if source in bls:51 backward_links_dict[source][1] = target52 continue53 elif target in bls:54 backward_links_dict[target][0] = source55 continue56 if source in dls:57 direct_links_dict[source][1] = target58 continue59 elif target in dls:60 direct_links_dict[target][0] = source61 continue62 source_mm = mms[source]63 target_mm = mms[target]64 if target_mm != "paired_with" and not has_contains:65 if source_mm == "MatchModel":66 match_elements.append(target)67 elif source_mm == "ApplyModel":68 apply_elements.append(target)69 else:70 if source_mm == "match_contains":71 match_elements.append(target)72 elif source_mm == "apply_contains":73 apply_elements.append(target)74 direct_links = [[val[0], val[1], dl] for dl, val in direct_links_dict.items()]75 if debug:76 print("Direct links: ")77 for n0, n1, nlink in direct_links:78 NewHimesisMatcher.print_link(None, graph, n0, n1, nlink)79 backward_links = [[val[0], val[1], bl] for bl, val in backward_links_dict.items()]80 if debug:81 print("Backward links: ")82 for n0, n1, nlink in backward_links:83 NewHimesisMatcher.print_link(None, graph, n0, n1, nlink)84 # for matchers, there might not be a match model85 if "MatchModel" not in mms:86 link_mms = ["directLink_S", "directLink_T", "backward_link", "trace_link"]87 match_elements = [i for i in range(len(mms)) if mms[i] not in link_mms]88 # find the non-isolated elements89 isolated_match_elements = []90 if get_isolated_match_elements:91 links = direct_links[:]92 if not isolated_if_attached_backward:93 links += backward_links94 for me in match_elements:95 isolated = True96 for dl in links:97 if me == dl[0] or me == dl[1]:98 isolated = False99 break100 if isolated:101 isolated_match_elements.append(me)102 if debug:103 print("\nRule name: " + graph.name)104 print("Match contains: " + str(match_elements))105 print("Isolated match elements: " + str(isolated_match_elements))106 print("Apply contains: " + str(apply_elements))107 graph_to_dot(graph.name, graph)108 #raise Exception()109 data = {"direct_links" : direct_links, "backward_links" : backward_links, "match_elements" : match_elements, "isolated_match_elements" : isolated_match_elements, "apply_elements" : apply_elements}...

Full Screen

Full Screen

models.py

Source:models.py Github

copy

Full Screen

1import uuid2from django.db import models3from django.utils.translation import ugettext_lazy as _4from django.conf import settings5from django.contrib.postgres.fields import JSONField6from model_utils.models import TimeStampedModel7from apps.documents.choices import STATUS_CHOICES8from apps.core.models import BaseModel9user_model = settings.AUTH_USER_MODEL10class Country(BaseModel):11 name = models.CharField(max_length=100)12 abbr = models.CharField(max_length=50, unique=True)13 def __str__(self):14 return self.name15 class Meta:16 verbose_name = _('Country')17 verbose_name_plural = _('Countrys')18class Type(BaseModel):19 name = models.CharField(max_length=100)20 abbr = models.CharField(max_length=50, unique=True)21 def __str__(self):22 return self.name23 class Meta:24 verbose_name = _('Type')25 verbose_name_plural = _('Types')26class Model(BaseModel):27 country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name='models')28 type = models.ForeignKey(Type, on_delete=models.CASCADE, related_name='models')29 name = models.CharField(max_length=100)30 abbr = models.CharField(max_length=50)31 def __str__(self):32 return self.name33 class Meta:34 verbose_name = _('Model')35 verbose_name_plural = _('Models')36 unique_together = (("country", "type", "abbr"),)37class Document(TimeStampedModel, BaseModel):38 ref = models.CharField(max_length=300)39 error = models.CharField(max_length=300, null=True)40 model = models.ForeignKey(Model, on_delete=models.CASCADE)41 file = models.URLField()42 status = models.CharField(max_length=30, choices=STATUS_CHOICES, verbose_name=_("status"), default=STATUS_CHOICES.pending)43 user = models.ForeignKey(user_model, related_name='user', on_delete=models.CASCADE)44 webhook = models.URLField()45 tries = models.IntegerField(default=0)46 request_id = models.UUIDField(default=uuid.uuid4, null=True)47 is_ready = models.BooleanField(default=False)48 contains = JSONField(default={})49 has_contains = models.BooleanField(default=False)50 ocr = models.TextField(null=True)51 def __str__(self):52 return '{} | {} - {} - {}'.format(self.user.username, self.model.country.name, self.model.type.name, self.model.name)53 def set_ocr_text(self, text):54 self.ocr = text55 self.save()56 def send_to_recognition(self):57 self.has_contains = True58 self.save()59 def increment_tries(self, error):60 self.error = error61 self.tries += 162 self.save()63 def send_to_validation(self, contains):64 self.error = None65 self.tries = 066 self.is_ready = True67 self.contains = contains68 self.save()69 class Meta:70 verbose_name = _('Document')71 verbose_name_plural = _('Documents')72class Requests(BaseModel):73 timestamp = models.DateTimeField(auto_now_add=True)...

Full Screen

Full Screen

0007_document_has_contains.py

Source:0007_document_has_contains.py Github

copy

Full Screen

1# Generated by Django 2.0.3 on 2018-04-28 16:392from django.db import migrations, models3class Migration(migrations.Migration):4 dependencies = [5 ('documents', '0006_document_ocr'),6 ]7 operations = [8 migrations.AddField(9 model_name='document',10 name='has_contains',11 field=models.BooleanField(default=False),12 ),...

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 pyresttest 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