-
Notifications
You must be signed in to change notification settings - Fork 1
/
des_arch_test.py
95 lines (69 loc) · 3.1 KB
/
des_arch_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import time
from getpass import getpass
from login_test import login_test as login
import lib.shared_lib as shared
import utils.datetime_id as id
import os
import traceback
import pandas as pd
from datetime import datetime
import random
import data.data_api as data_api
ROLES = ['Solicitante']
IDS = []
FILES = []
def des_arch_test(driver, DF, caso, rol, id, file, username):
UAC = 1
passed = 0
FUNC_STR = 'Descargar Archivo'
PARAMS_STR = f"ID: {id}\nFile: {'Soporte' if file == 0 else 'Certificado'}\nUsername: {username}"
try:
shared.select_role(driver, rol)
time.sleep(5)
shared.select_module(driver, 'Mis solicitudes')
time.sleep(10)
shared.search(driver, 'Mis Solicitudes', id)
time.sleep(10)
shared.descargar_soporte(driver, 0)
time.sleep(5)
# [UAC] El archivo se descarga correctamente y con el nombre correcto
file_name_substr = f'{username}_{id}'
result = shared.UAC_validate_downloaded_filename(file_name_substr, file)
passed += shared.evaluate_UAC_result(result)
DF = data_api.write_row_to_df(DF, caso, FUNC_STR, rol, PARAMS_STR,
'El archivo se descarga correctamente y con el nombre correcto',
f"{'SI' if result[0] else 'NO'} : {result[1]}",
'PASSED' if result[0] else 'FAILED')
# END UAC CHECK
print(f'DES ARCH: {passed}/{UAC} UAC PASSED')
except Exception as e:
traceback.print_exc()
DF = data_api.write_row_to_df(DF, caso, FUNC_STR, rol, PARAMS_STR, 'EXCEPTION', e, 'EXCEPTION')
print(f'DES ARCH: {passed}/{UAC} UAC PASSED')
return DF
if __name__ == "__main__":
DF = pd.DataFrame(columns=['CASO', 'FUNCIONALIDAD', 'ROL', 'PARAMS', 'UAC', 'SALIDA', 'RESULTADO'])
driver = shared.init_driver()
username = input('Username: ')
login(driver, username, getpass('Password: '))
start_time = time.time()
total_time = 0
nexp = 10
wait = 30
for i in range(nexp):
rol = random.choice(ROLES)
id_ = IDS[i]
file = FILES[i]
DF = des_arch_test(driver, DF, caso=i+1, rol=rol, id=id_, file=file, username=username)
iteration_time = time.time() - start_time - total_time
total_time += iteration_time
print(f"Caso {i+1} tomó: {datetime.timedelta(seconds=iteration_time)}")
print(f"Caso {i+1} sin espera tomó aprox.: {datetime.timedelta(seconds=iteration_time - wait)}")
avg_time_per_iteration = total_time / nexp
total_time = time.time() - start_time
print('\n\n\n')
print(f"Tiempo promedio por caso: {datetime.timedelta(seconds=avg_time_per_iteration)}")
print(f"Tiempo promedio aprox. por caso sin espera: {datetime.timedelta(seconds=avg_time_per_iteration - wait)}")
print(f"Tiempo total para {nexp} casos: {datetime.timedelta(seconds=total_time)}")
print(f"Tiempo total aprox. para {nexp} casos sin espera: {datetime.timedelta(seconds=total_time - wait * nexp)}")
DF.to_excel(r'results\des_arch_test_results.xlsx', index=False)