
Listas y diccionarios
https://devcode.la/tutoriales/diccionarios-en-python/
https://devcode.la/tutoriales/listas-python/
Expresiones regulares:
https://docs.python.org/3/library/re.html
https://docs.hektorprofe.net/python/funcionalidades-avanzadas/expresiones-regulares/
Ejemplos:
text = "ID: 2541684 Esta es una de las mejores clases de testing en Udemy expresion 2541684"
matching = re.findall('CLASES|udemy', text, re.IGNORECASE)
for result in matching:
print(result)
------------------------------------------------------------------------------------------------------
text = "ID: 2541684 Esta es una de las mejores clases de testing en Udemy expresion 2541684"
search = re.search('2541684', text, re.IGNORECASE)
print(search)
if search:
print ("Se encontro el valor")
text = re.sub('2541684','******', text, re.IGNORECASE)
else:
print("No se encontro el valor")
print(text)
-----------------------------------------------------------------------------------------------
text = "ID:2541684, Esta es una, de las mejores, clases de testing, en Udemy expresion 2541684"
split = re.split(',', text)
for result in split:
print(result)
if result == "ID:2541684":
print("Se encontro el codigo")
break
-------------------------------------------------------------------------------------------------
Scenario = {}
text = "Este texto contiene el valor del MyID_Venta:8952654 ahora"
PatronDeBusqueda = r"(?<=MyID_Venta:)\w+"
variables = re.findall(str(PatronDeBusqueda), text, re.IGNORECASE)
print (variables)
Scenario['btprcnro'] = str(variables[0])
print("Se almaceno el btprcnro = " + Scenario['btprcnro'])
------------------------------------------------------------------------------------------------
Ejemplos:
text = "Este texto contiene el valor del Scenario:HOY ahora"
PatronDeBusqueda = r"(?<=Scenario:)\w+"
variables = re.findall(str(PatronDeBusqueda), text, re.IGNORECASE)
for variable in variables:
if variable == 'HOY':
dateToday = str(datetime.date.today().strftime("%d-%m-%Y"))
text = re.sub('(Scenario:)([^&.]+)', dateToday, text, re.IGNORECASE)
continue
print(text)
----------------------------------------------------------------------------------------------
API_hostAddressBase = u'http:\\UrlDeLaWebapi.com'
partHost = "\Endpoint\FECHA\Scenario:Today"
def get_full_host(_PartHost):
_RegexPartHost = str(ReplaceWithContextValues(_PartHost))
_endpoint = API_hostAddressBase + _RegexPartHost
print(_endpoint)
return _endpoint
def ReplaceWithContextValues(text):
PatronDeBusqueda = r"(?<=Scenario:)\w+"
variables = re.findall(str(PatronDeBusqueda), text, re.IGNORECASE)
for variable in variables:
if variable == 'Today':
dateToday = str(datetime.date.today().strftime("%Y-%m-%d"))
text = re.sub('(Scenario:)([^&.]+)', dateToday, text, re.IGNORECASE)
continue
return text
endpoint = get_full_host(partHost)
echo. ##################### TEST PATH #####################
python -m pytest UnitTestTrue.py UnitTest002.py Pytest.py --junit-xml=../results/results.xml
pause
APIs de ejemplo
https://docs.api.bible/reference
https://petstore.swagger.io/
https://api.nasa.gov/index.html
https://gorest.co.in/
vayan chusmeando esta otra:
https://developer.twitter.com/
Acá les dejo la documentacion oficial de Request:
https://2.python-requests.org/en/v2.9.1/
y otra guía de un sitio que frecuento mucho:
https://realpython.com/python-requests/
Guía de Postman:
https://medium.com/@cesiztel/c%C3%B3mo-se-hace-api-testing-con-postman-978a521552f4
Pet Store:
https://petstore.swagger.io/
NASA:
https://api.nasa.gov/index.html
Biblia:
https://docs.api.bible/reference#authentication
FORMATOS DE SALIDAS:
.XML
behave --junit --tags=-skip --no-skipped
BEHAVE BASICO
behave -f allure_behave.formatter:AllureFormatter -o .\allure-results -f pretty
Behave Avanzado!
behave -f allure_behave.formatter:AllureFormatter --tags=Integration --tags=-skip --no-skipped -o .\allure-results ./features -f pretty
behave debe ejecutarse donde se encuentre la carpeta "features"
./features ejecutar las pruebas desde otra carpeta
--tags=-skip --no-skipped Ocultar las pruebas skipped para el reporte
--tags=Integration tag de las pruebas
-o .\allure-results Salida de los resultados
-f pretty Estilizar la salida por consola
https://behave.readthedocs.io/en/latest/install.html
Sitio Oficial:
https://docs.qameta.io/allure/
Descarga de allure commandline
https://bintray.com/qameta/maven/allure2/2.9.0
allure generate .\allure-results --output .\allure-report --clean && allure open --port 5000
allure generate Generar un nuevo reporte (ya debe existir la carpeta de resultados) .\allure-results
--output .\allure-report Salida de los datos del reporte. Si ya existe un reporte anterior aplicar --clean
allure open --port 5000 Abrir un nuevo reporte en el puerto 5000 de tu localhost.
Descargalo en: https://jenkins.io/download/
Git
https://github.com/MervinDiazLugo/Udemy.ApiTesting.Python.git
En este curso encontraras
Temario Basico:
Introducción a API REST
¿Qué son las APIs y para qué sirven?
Las APIs y el testing
¿Qué es Unit testing?
Librerias Unittest / pytest
Ciclo de vida de las Pruebas Automatizadas.
Temas técnicos:
Postman
Curl
Python orientado a pruebas de software.
Estructuras de datos.
Framworks de pruebas con python.
Preparacion de entornos Windows
Jenkins
Pipelines de ejecucion de pruebas.
Lenguaje: Python 3.4 o superior.
Librerías:
Pytest,
Unittest,
Requests,
Re (Regular Expressions),
Time,
json.
Allure (para reportes)
ObjectPath.