How to use data_session method in yandex-tank

Best Python code snippet using yandex-tank

main.py

Source:main.py Github

copy

Full Screen

1from teacher_manager import TeacherManager 2from student_manager import StudentManager3teacher_manager = TeacherManager()4student_manager = StudentManager()5data_session = {}6def prevet_error(f):7 def wrapper(*args, **kwargs):8 try:9 f(*args, **kwargs)10 except: 11 print('Se presentó un error vuelve a correr el programa')12 return wrapper13@prevet_error14def start():15 print('******************Bienvenido********************')16 role = int(input('Selecciona 0 si eres profesor ó 1 si eres estudiante'))17 register = int(input('\nDigita 0 si deseas registrarte ó 1 si deseas hacer login'))18 data_session['role'] = role19 if(register == 1):20 document = input('Digita tu número de documento')21 if role == 0:22 result = teacher_manager.loginTeacher(document)23 if result == None:24 print('El usuario no existe')25 start()26 for key,value in result.items():27 data_session[key] = value28 welcome_teacher()29 else:30 result = student_manager.loginStudent(document)31 if result == None:32 print('El usuario no existe')33 start()34 for key,value in result.items():35 data_session[key] = value36 welcome_student()37 else:38 if role == 0:39 register_teacher()40 else:41 register_student()42def welcome_teacher():43 if len(data_session) > 0:44 print('\n **************** Hola docente '+ data_session.get('name_teacher')+ ' ****************')45 var = int(input('\n Digita 0 si desea registrarse en una materia ó 1 si desea registrar una calificación'))46 if var == 0:47 register_asignature_teacher()48 else:49 register_calification()50def register_teacher():51 print('****************** REGISTRO DE NUEVO DOCENTE ******************')52 document = input('Digita tu número de documento')53 name_teacher = input('Digita tu nombre completo')54 teacherChecked = teacher_manager.loginTeacher(document)55 if teacherChecked == None:56 registerTeacher = teacher_manager.registerNewTeacher(document,name_teacher)57 if registerTeacher == True:58 result = teacher_manager.loginTeacher(document)59 for key,value in result.items():60 data_session[key] = value61 welcome_teacher()62 else:63 print('No fue posible hacer el registro')64 else:65 print('Este docente ya existe en el sistema')66 register_teacher()67def viewAsignatureTeacher():68 asignatures_by_teacher = {}69 rows = teacher_manager.getAsignaturesByTeacher(data_session.get('id'))70 if len(rows) > 0:71 print('****************** Tienes asignadas las siguientes materias ****************** ')72 for row in rows:73 asignatures_by_teacher[row['name_asignature']] = row['id_asignature']74 print(row['name_asignature'])75 else:76 print('No tienes asignadas materias')77 asignatures_by_teacher = {}78def register_asignature_teacher():79 viewAsignatureTeacher()80 rows = teacher_manager.getAsignatures()81 sentence = ""82 for row in rows:83 sentence += 'Digita {} para registrarse en {} \n '.format(row['id'],row['name_asignature'])84 asignatureForRegister = int(input(sentence))85 asignatureCheck = teacher_manager.getOneGroupByTeacher(asignatureForRegister,data_session.get('id'))86 if len(asignatureCheck) == 0:87 registerAsignatureByTeacher = teacher_manager.registerAsignatureByTeacher(asignatureForRegister,data_session.get('id'))88 if registerAsignatureByTeacher == True:89 print('Se ha registrado la materia con exito')90 viewAsignatureTeacher()91 again = int(input('Digita 0 para ingresar otra materia ó 1 para regresar al menu'))92 if again == 1:93 welcome_teacher()94 else:95 register_asignature_teacher()96 else:97 back = int(input('Esta materia ya esta registrada, digita 0 para probar con otra materia ó 1 para volver al menu'))98 if back == 1:99 welcome_teacher()100 else:101 register_asignature_teacher()102 103def register_calification():104 rows = teacher_manager.getAsignaturesByTeacher(data_session.get('id'))105 sentence = ""106 print('****************** ******************' )107 if len(rows) > 0:108 for row in rows:109 sentence += 'Digita {} para mostrar estudiantes de {} \n '.format(row['id_group'],row['name_asignature'])110 id_group = int(input(sentence))111 rows = teacher_manager.getStudentsByGroup(id_group)112 sentence = ""113 if len(rows)>0:114 for row in rows:115 sentence += 'Digita {} para registrar nota a {} \n '.format(row['id_student'],row['name_student'])116 id_student = int(input(sentence))117 value = float(input('Digite la nota a registrar'))118 registerCalification = teacher_manager.registerCalification(id_group,id_student,value)119 if registerCalification == True:120 print('Se ha registrado la calificación con exito')121 again = int(input('Digita 0 para ingresar otra calificacion ó 1 para regresar al menu'))122 if again == 1:123 welcome_teacher()124 else:125 register_calification()126 else:127 back = int(input('No hay estudiantes registrados para esta materia, digita 0 para probar con otra materia ó 1 para volver al menu'))128 if back == 1:129 welcome_teacher()130 else:131 register_calification()132 else:133 print('No hay materias registradas para usted')134 welcome_teacher()135def welcome_student():136 if len(data_session) > 0:137 print('\n **************** Hola estudiante '+ data_session.get('name_student')+ ' ****************')138 var = int(input('\n Digita 0 si desea registrarse en una materia ó 1 si desea ver sus calificaciónes'))139 if var == 0:140 register_asignature_student()141 else:142 view_calification_student()143 144def register_student():145 print('****************** REGISTRO DE NUEVO ESTUDIANTE ******************')146 document = input('Digita tu número de documento')147 name_student = input('Digita tu nombre completo')148 studentChecked = student_manager.loginStudent(document)149 if studentChecked == None:150 registerStudent = student_manager.registerNewStudent(document,name_student)151 if registerStudent == True:152 result = student_manager.loginStudent(document)153 for key,value in result.items():154 data_session[key] = value155 welcome_student()156 else:157 print('No fue posible hacer el registro')158 else:159 print('Este estudiante ya existe en el sistema')160 register_student()161def view_asignatures_student():162 asignatures_by_student = {}163 rows = student_manager.getAsignaturesByStudent(data_session.get('id'))164 if len(rows) > 0:165 print('****************** Tienes registradas las siguientes materias ****************** ')166 for row in rows:167 asignatures_by_student[row['name_asignature']] = row['id_group']168 print(row['name_asignature'])169 else:170 print('No tienes registradas materias')171 asignatures_by_student = {}172def register_asignature_student():173 view_asignatures_student()174 rows = student_manager.getGroups()175 if len(rows)>0:176 sentence = ""177 for row in rows:178 sentence += 'Digita {} para registrarse en {} con el docente {} \n'.format(row['id'],row['name_asignature'],row['name_teacher'])179 id_group = int(input(sentence))180 print(data_session)181 groupCheck = student_manager.getGroupByStudent(id_group,data_session.get('id'))182 if len(groupCheck) == 0:183 registerInGroup = student_manager.registerInGroup(id_group,data_session.get('id'))184 if registerInGroup == True:185 print('Se ha registrado la materia con exito')186 view_asignatures_student()187 again = int(input('Digita 0 para registrarse en otro grupo ó 1 para regresar al menu'))188 if again == 1:189 welcome_student()190 else:191 register_asignature_student()192 else:193 back = int(input('Ya estas registrado en este grupo, digita 0 para probar con otra grupo ó 1 para volver al menu'))194 if back == 1:195 welcome_student()196 else:197 register_asignature_student()198 else:199 print('No hay grupos registrados en este momento')200 welcome_student()201def view_calification_student():202 rows = student_manager.getAsignaturesByStudent(data_session.get('id'))203 print('**************** VER LAS NOTAS POR MATERIA **********************')204 sentence =""205 if len(rows):206 for row in rows:207 sentence += 'Digita {} para ver las notas de {} \n'.format(row['id_group'],row['name_asignature'])208 id_group = int(input(sentence)) 209 210 rows = student_manager.getCalificationsByGroupStudent(id_group,data_session.get('id'))211 if len(rows)>0:212 i = 0213 sumNotes = 0 214 for row in rows:215 i = i+1216 print('{}. Materia {}, calificacion: {}'.format(i,row['name_asignature'],row['value']))217 sumNotes += float(row['value'])218 name_asignature = row['name_asignature']219 avgNotes = sumNotes/i220 print('Su promedio en {} es de {}'.format(name_asignature,avgNotes))221 again = int(input('Digite 0 para consultar las notas de otra materia ó 1 para volver al menu'))222 if again == 0:223 view_calification_student()224 else:225 welcome_student()226 else:227 again = int(input('No hay notas asignadas para esta materia, digita 0 para intentar de nuevo ó 1 para ir al menu'))228 if again == 0:229 view_calification_student()230 else:231 welcome_student()232 else: 233 again = int(input('No hay calificaciones para esta mataeria,\nDigita 0 para ver las notas de otra materia, \n ó 1 para volver al menu'))234 if again == 1:235 welcome_student()236 else:237 view_calification_student()238def clear_data():239 data_session = {}...

Full Screen

Full Screen

core_container.py

Source:core_container.py Github

copy

Full Screen

1from dependency_injector import containers, providers2from flask_bcrypt import Bcrypt3from .services.logging import Logging4from .services.pg_data_session import PgDataSession5from .services.password_tools import PasswordTools6from .services.entities import Entities7from .services.employees import Employees8from .entities.category import Category9from .entities.product import Product10from .entities.supplier import Supplier11from .entities.car import Car12from .entities.color import Color13class Adapters(containers.DeclarativeContainer):14 config = providers.Configuration()15 logging = providers.Factory(16 Logging,17 )18 bcrypt = providers.Factory(19 Bcrypt,20 )21 data_session = providers.Factory(22 PgDataSession,23 url=config.database.url,24 name=config.database.name,25 user=config.database.user,26 password=config.database.password27 )28 password_tools = providers.Factory(29 PasswordTools,30 bcrypt=bcrypt31 )32 categories = providers.Factory(33 Entities,34 logging=logging,35 data_session=data_session,36 model=Category,37 model_key_field='category_id'38 )39 employees = providers.Factory(40 Employees,41 logging=logging,42 data_session=data_session,43 )44 suppliers = providers.Factory(45 Entities,46 logging=logging,47 data_session=data_session,48 model=Supplier,49 model_key_field='supplier_id'50 )51 products = providers.Factory(52 Entities,53 logging=logging,54 data_session=data_session,55 model=Product,56 model_key_field='product_id'57 )58 cars = providers.Factory(59 Entities,60 logging=logging,61 data_session=data_session,62 model=Car,63 model_key_field='car_id'64 )65 colors = providers.Factory(66 Entities,67 logging=logging,68 data_session=data_session,69 model=Color,70 model_key_field='color_id'...

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 yandex-tank 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