Best Python code snippet using SeleniumBase
queries.py
Source:queries.py
1import graphene2from graphene_django_extras import (3 DjangoObjectType, DjangoListObjectType, DjangoListObjectField, DjangoObjectField4)5from django.urls import reverse6from .. import filters7from .. import models8from .. import utils9class Formato(DjangoObjectType):10 class Meta:11 model = models.Formato12 description = 'Son los distintos formatos para las historias.'13class FormatoList(DjangoListObjectType):14 class Meta:15 model = models.Formato16 description = 'Definición del tipo para una lista de formatos.'17 filterset_class = filters.FormatoFilter18class Archivo(graphene.ObjectType):19 url = graphene.String(required=True)20 nombre = graphene.String(required=True)21 def resolve_url(self, info):22 return self.url23 def resolve_nombre(self, info):24 return self.name.split('/')[-1]25class Adjunto(DjangoObjectType):26 archivo = graphene.Field(Archivo, required=True)27 class Meta:28 model = models.Adjunto29 def resolve_archivo(self, info, **kwarg):30 return self.archivo31class Historia(DjangoObjectType):32 can_abrir = graphene.Boolean(description='Indica si puede abrir el encuentro')33 can_edit = graphene.Boolean(description='Indica si puede editar el encuentro')34 can_delete = graphene.Boolean(description='Indica si puede borrar el encuentro')35 print_content = graphene.JSONString(description='Contenido de la historia para imprimir')36 print_url = graphene.String(source='print_url', description='URL para la impresión del encuentro')37 detail_url = graphene.String(source='get_absolute_url', description='URL del detalle del encuentro')38 adjuntos_url = graphene.String(source='adjuntos_url', description='URL de los adjuntos del encuentro')39 visita_url = graphene.String(source='visita_url', description='URL de la visita a la cual se encuentra asociada el encuentro')40 class Meta:41 model = models.Historia42 description = 'Una historia guarda la información medica de un paciente'43 44 def resolve_can_abrir(self, info, **kwargs):45 return self.can_abrir(info.context.user)46 def resolve_can_edit(self, info, **kwargs):47 return self.can_edit(info.context.user)48 49 def resolve_can_delete(self, info, **kwargs):50 return self.can_delete(info.context.user)51 def resolve_print_content(self, info, **kwargs):52 return info.context.dataloaders.print_content_by_historia.load(self.id)53 def resolve_proveedor(self, info, **kwargs):54 return info.context.dataloaders.proveedor_by_historia.load(self.id)55 def resolve_formato(self, info, **kwargs):56 return info.context.dataloaders.formato_by_historia.load(self.id)57class HistoriaList(DjangoListObjectType):58 class Meta:59 model = models.Historia60 description = 'Definición del tipo de una lista de historias'61 filterset_class = filters.HistoriaFilter62class Query:63 historias = DjangoListObjectField(HistoriaList, description='Lista de todas las historias')64 formatos = DjangoListObjectField(FormatoList, description='Lista de todos los formatos')65 encuentro = DjangoObjectField(Historia, description='Un solo encuentro')...
serializers.py
Source:serializers.py
1from rest_framework import serializers2from .relations import VisiteCustomHyperlinkedIdentityField, \3 PazientiCustomHyperlinkedIdentityField4from .models import Visita5class VisitaSerializer(serializers.ModelSerializer):6 owner = serializers.ReadOnlyField(source='owner.username')7 paziente_url = PazientiCustomHyperlinkedIdentityField(view_name='pazienti-detail')8 visita_url = VisiteCustomHyperlinkedIdentityField(view_name='visite-detail', read_only=False)9 class Meta:10 model = Visita11 fields = ('id', 'data_visita', 'owner', 'paziente_url', 'visita_url')12class VisitaDetailSerializer(serializers.ModelSerializer):13 owner = serializers.ReadOnlyField(source='owner.username')14 paziente_url = PazientiCustomHyperlinkedIdentityField(view_name='pazienti-detail')15 visita_url = VisiteCustomHyperlinkedIdentityField(view_name='visite-detail', read_only=False)16 class Meta:17 model = Visita18 fields = ('id', 'anamnesi', 'esame_obiettivo', 'conclusioni', 'owner',...
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!!