SlideShare a Scribd company logo
1 of 4
Lettuce example using scenarios
outline:
El siguiente ejemplo tiene tres archivos, un feature y dos py. En el siguiente ejemplo
atacaremos la api del tiempo y comprobaremos que ciertos valores sean correctos. Para ello
utilizaremos lettuce con python. Además utilizaremos scenarios Outline.
Weather2.feature:
Feature: Check if the weather service works properly
In order to check the weather service
As beginner
I'll get some values and check if they are ok and if the temperature given is correct
Scenario Outline: Check if a city and and country given are correct
Given I access the url with http://api.openweathermap.org/data/2.5/weather
And the city is <city> and the country <country>
When I ask for the city and country name
Then I check if the city and country are correct
And I check if the status code is 200
Examples:
| city | country |
| London | GB |
| Madrid | ES |
| Barcelona | ES |
Scenario Outline: Check if a latitude and longitude given are correct
Given I access the url with http://api.openweathermap.org/data/2.5/weather
And the latitude is <latitude> and the longitude <longitude>
When I ask for the latitude and longitude
Then I check if the latitude and longitude are correct
And I check if the status code is 200
Examples:
| latitude | longitude |
| 51.51 | -0.13 |
| 40.42 | 3.7 |
| 10.13 | -64.7 |
Scenario Outline: Check if the temperature is correct given a city and a country
Given I access the url with http://api.openweathermap.org/data/2.5/weather
And the city is <city> and the country <country>
When I ask for the city and country name
Then I get the temperature look by city and country
Examples:
| city | country |
| London | GB |
| Madrid | ES |
| Barcelona | ES |
Scenario Outline: Check if the temperature is correct given the latitude and longitude
Given I access the url with http://api.openweathermap.org/data/2.5/weather
And the latitude is <latitude> and the longitude <longitude>
When I ask for weather information by latitude and longitude
Then I get the temperature look by latitude and longitude
Examples:
| latitude | longitude |
| 51.51 | -0.13 |
| 40.42 | 3.7 |
| 10.13 | -64.7 |
Weather2.py:
__author__ = 'kwiznia'
import requests
from lettuce import world
import json
class weather2():
"""
def getStatus_code(self, response):
world.response = response
world.response = requests.get(response)
return world.response.status_code
"""
def getInformation(self, response):
world.response = requests.get(response)
return world.response.json()
weather2steps.py:
__author__ = 'kwiznia'
from lettuce import *
from weather2 import *
from nose.tools import *
weather2 = weather2()
@step("I access the url with (.*)")
def access_url(self, expectedUrl):
world.expectedUrl = expectedUrl
assert_regexp_matches(world.expectedUrl, '^http'), "The URL is empty"
@step('the city is ([^"]+) and the country ([^"]+)')
def city_and_country(self, expectedCity, expectedCountry):
world.expectedCity = expectedCity
world.expectedCountry = expectedCountry
@step("I ask for the city and country name")
def ask_for_city_and_country(self):
world.url = world.expectedUrl + "?q=" + world.expectedCity + "," + world.expectedCountry
world.page_info = weather2.getInformation(world.url)
@step("I check if the city and country are correct")
def check_city_and_country_are_correct(self):
sys = world.page_info['sys']
assert sys != ""
assert world.expectedCity in world.page_info['name']
assert world.expectedCountry in sys['country']
@step("I check if the status code is 200")
def check_status_code(self):
assert_equals(world.response.status_code, 200), "page not found"
@step('the latitude is ([^"]+) and the longitude ([^"]+)')
def check_lat_and_long(self, expectedLatitude, expectedLongitude):
world.expectedLatitude = expectedLatitude
world.expectedLongitude = expectedLongitude
@step("I ask for the latitude and longitude")
def ask_for_lat_and_long(self):
world.url = world.expectedUrl + "?lat=" + world.expectedLatitude + "&lon=" +
world.expectedLongitude
world.page_info = weather2.getInformation(world.url)
@step("I check if the latitude and longitude are correct")
def check_lat_and_long_are_correct(self):
latlon = world.page_info['coord']
assert latlon['lon'] != ""
assert latlon['lat'] != ""
assert_equals(float(world.expectedLatitude), latlon['lat'])
assert_equals(float(world.expectedLongitude), latlon['lon'])
@step("I get the temperature look by city and country")
def get_temperature_look_by_city(self):
temperature = world.page_info['main']
temperatuce_farenhait = temperature['temp']
assert temperatuce_farenhait != ""
@step("I ask for weather information by latitude and longitude")
def ask_for_weather_information_by_latlong(self):
world.url = world.expectedUrl + "?lat=" + world.expectedLatitude + "&lon=" +
world.expectedLongitude
world.page_info_by_latlon = weather2.getInformation(world.url)
@step("I get the temperature look by latitude and longitude")
def get_temperature_by_latlong(self):
temperature = world.page_info_by_latlon['main']
temperatuce_farenhait = temperature['temp']
assert temperatuce_farenhait != ""

More Related Content

Similar to Lettuce example using scenarios outline

Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineAndy McKay
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Joe Keeley
 
Code implementation.pptx
Code implementation.pptxCode implementation.pptx
Code implementation.pptxAasimAbdul
 
Analyzing Air Quality Measurements in Macedonia with Apache Drill
Analyzing Air Quality Measurements in Macedonia with Apache DrillAnalyzing Air Quality Measurements in Macedonia with Apache Drill
Analyzing Air Quality Measurements in Macedonia with Apache DrillMarjan Sterjev
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiInfluxData
 
Predicting landing distance: Adrian Valles
Predicting landing distance: Adrian VallesPredicting landing distance: Adrian Valles
Predicting landing distance: Adrian VallesAdrián Vallés
 
In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfivylinvaydak64229
 
Mp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMontreal Python
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Tomasz Dziuda
 
PhoneGap - Hardware Manipulation
PhoneGap - Hardware ManipulationPhoneGap - Hardware Manipulation
PhoneGap - Hardware ManipulationDoncho Minkov
 
Context-aware application development with FIWARE #CPBR8
Context-aware application development with FIWARE #CPBR8Context-aware application development with FIWARE #CPBR8
Context-aware application development with FIWARE #CPBR8Fermin Galan
 
Weather scraper for your data warehouse
Weather scraper for your data warehouseWeather scraper for your data warehouse
Weather scraper for your data warehouseFru Louis
 
Angular Promises and Advanced Routing
Angular Promises and Advanced RoutingAngular Promises and Advanced Routing
Angular Promises and Advanced RoutingAlexe Bogdan
 
Classic Games Development with Drools
Classic Games Development with DroolsClassic Games Development with Drools
Classic Games Development with DroolsMark Proctor
 
rules, events and workflow
rules, events and workflowrules, events and workflow
rules, events and workflowMark Proctor
 
REST meets Semantic Web
REST meets Semantic WebREST meets Semantic Web
REST meets Semantic WebSteve Speicher
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptViliam Elischer
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Claire Townend Gee
 

Similar to Lettuce example using scenarios outline (20)

Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019
 
Code implementation.pptx
Code implementation.pptxCode implementation.pptx
Code implementation.pptx
 
Analyzing Air Quality Measurements in Macedonia with Apache Drill
Analyzing Air Quality Measurements in Macedonia with Apache DrillAnalyzing Air Quality Measurements in Macedonia with Apache Drill
Analyzing Air Quality Measurements in Macedonia with Apache Drill
 
huhu
huhuhuhu
huhu
 
app.js.docx
app.js.docxapp.js.docx
app.js.docx
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
 
Predicting landing distance: Adrian Valles
Predicting landing distance: Adrian VallesPredicting landing distance: Adrian Valles
Predicting landing distance: Adrian Valles
 
In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdf
 
Mp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook game
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015
 
PhoneGap - Hardware Manipulation
PhoneGap - Hardware ManipulationPhoneGap - Hardware Manipulation
PhoneGap - Hardware Manipulation
 
Context-aware application development with FIWARE #CPBR8
Context-aware application development with FIWARE #CPBR8Context-aware application development with FIWARE #CPBR8
Context-aware application development with FIWARE #CPBR8
 
Weather scraper for your data warehouse
Weather scraper for your data warehouseWeather scraper for your data warehouse
Weather scraper for your data warehouse
 
Angular Promises and Advanced Routing
Angular Promises and Advanced RoutingAngular Promises and Advanced Routing
Angular Promises and Advanced Routing
 
Classic Games Development with Drools
Classic Games Development with DroolsClassic Games Development with Drools
Classic Games Development with Drools
 
rules, events and workflow
rules, events and workflowrules, events and workflow
rules, events and workflow
 
REST meets Semantic Web
REST meets Semantic WebREST meets Semantic Web
REST meets Semantic Web
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScript
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0
 

More from Karen Wiznia

Anteproyecto - código - Video final
Anteproyecto - código - Video finalAnteproyecto - código - Video final
Anteproyecto - código - Video finalKaren Wiznia
 
Arduino - código - video
Arduino - código - videoArduino - código - video
Arduino - código - videoKaren Wiznia
 
Arduino - telesketch automático
Arduino - telesketch automáticoArduino - telesketch automático
Arduino - telesketch automáticoKaren Wiznia
 
Requests lettuce y python
Requests lettuce y pythonRequests lettuce y python
Requests lettuce y pythonKaren Wiznia
 
Testing & selenium - examples
Testing & selenium - examplesTesting & selenium - examples
Testing & selenium - examplesKaren Wiznia
 
Requests con lettuce y python
Requests con lettuce y pythonRequests con lettuce y python
Requests con lettuce y pythonKaren Wiznia
 
Selenium with lettuce and python
Selenium with lettuce and pythonSelenium with lettuce and python
Selenium with lettuce and pythonKaren Wiznia
 
Crear un repositorio con Gir Bash
Crear un repositorio con Gir BashCrear un repositorio con Gir Bash
Crear un repositorio con Gir BashKaren Wiznia
 

More from Karen Wiznia (9)

Anteproyecto - código - Video final
Anteproyecto - código - Video finalAnteproyecto - código - Video final
Anteproyecto - código - Video final
 
Arduino - código - video
Arduino - código - videoArduino - código - video
Arduino - código - video
 
Arduino - telesketch automático
Arduino - telesketch automáticoArduino - telesketch automático
Arduino - telesketch automático
 
Requests lettuce y python
Requests lettuce y pythonRequests lettuce y python
Requests lettuce y python
 
Testing & selenium - examples
Testing & selenium - examplesTesting & selenium - examples
Testing & selenium - examples
 
Requests con lettuce y python
Requests con lettuce y pythonRequests con lettuce y python
Requests con lettuce y python
 
Selenium with lettuce and python
Selenium with lettuce and pythonSelenium with lettuce and python
Selenium with lettuce and python
 
Crear un repositorio con Gir Bash
Crear un repositorio con Gir BashCrear un repositorio con Gir Bash
Crear un repositorio con Gir Bash
 
Malware
MalwareMalware
Malware
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 

Recently uploaded (20)

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 

Lettuce example using scenarios outline

  • 1. Lettuce example using scenarios outline: El siguiente ejemplo tiene tres archivos, un feature y dos py. En el siguiente ejemplo atacaremos la api del tiempo y comprobaremos que ciertos valores sean correctos. Para ello utilizaremos lettuce con python. Además utilizaremos scenarios Outline. Weather2.feature: Feature: Check if the weather service works properly In order to check the weather service As beginner I'll get some values and check if they are ok and if the temperature given is correct Scenario Outline: Check if a city and and country given are correct Given I access the url with http://api.openweathermap.org/data/2.5/weather And the city is <city> and the country <country> When I ask for the city and country name Then I check if the city and country are correct And I check if the status code is 200 Examples: | city | country | | London | GB | | Madrid | ES | | Barcelona | ES | Scenario Outline: Check if a latitude and longitude given are correct Given I access the url with http://api.openweathermap.org/data/2.5/weather And the latitude is <latitude> and the longitude <longitude> When I ask for the latitude and longitude Then I check if the latitude and longitude are correct And I check if the status code is 200 Examples: | latitude | longitude | | 51.51 | -0.13 | | 40.42 | 3.7 | | 10.13 | -64.7 | Scenario Outline: Check if the temperature is correct given a city and a country Given I access the url with http://api.openweathermap.org/data/2.5/weather And the city is <city> and the country <country> When I ask for the city and country name Then I get the temperature look by city and country Examples:
  • 2. | city | country | | London | GB | | Madrid | ES | | Barcelona | ES | Scenario Outline: Check if the temperature is correct given the latitude and longitude Given I access the url with http://api.openweathermap.org/data/2.5/weather And the latitude is <latitude> and the longitude <longitude> When I ask for weather information by latitude and longitude Then I get the temperature look by latitude and longitude Examples: | latitude | longitude | | 51.51 | -0.13 | | 40.42 | 3.7 | | 10.13 | -64.7 | Weather2.py: __author__ = 'kwiznia' import requests from lettuce import world import json class weather2(): """ def getStatus_code(self, response): world.response = response world.response = requests.get(response) return world.response.status_code """ def getInformation(self, response): world.response = requests.get(response) return world.response.json() weather2steps.py: __author__ = 'kwiznia' from lettuce import * from weather2 import * from nose.tools import * weather2 = weather2() @step("I access the url with (.*)") def access_url(self, expectedUrl): world.expectedUrl = expectedUrl assert_regexp_matches(world.expectedUrl, '^http'), "The URL is empty"
  • 3. @step('the city is ([^"]+) and the country ([^"]+)') def city_and_country(self, expectedCity, expectedCountry): world.expectedCity = expectedCity world.expectedCountry = expectedCountry @step("I ask for the city and country name") def ask_for_city_and_country(self): world.url = world.expectedUrl + "?q=" + world.expectedCity + "," + world.expectedCountry world.page_info = weather2.getInformation(world.url) @step("I check if the city and country are correct") def check_city_and_country_are_correct(self): sys = world.page_info['sys'] assert sys != "" assert world.expectedCity in world.page_info['name'] assert world.expectedCountry in sys['country'] @step("I check if the status code is 200") def check_status_code(self): assert_equals(world.response.status_code, 200), "page not found" @step('the latitude is ([^"]+) and the longitude ([^"]+)') def check_lat_and_long(self, expectedLatitude, expectedLongitude): world.expectedLatitude = expectedLatitude world.expectedLongitude = expectedLongitude @step("I ask for the latitude and longitude") def ask_for_lat_and_long(self): world.url = world.expectedUrl + "?lat=" + world.expectedLatitude + "&lon=" + world.expectedLongitude world.page_info = weather2.getInformation(world.url) @step("I check if the latitude and longitude are correct") def check_lat_and_long_are_correct(self): latlon = world.page_info['coord'] assert latlon['lon'] != "" assert latlon['lat'] != "" assert_equals(float(world.expectedLatitude), latlon['lat']) assert_equals(float(world.expectedLongitude), latlon['lon']) @step("I get the temperature look by city and country") def get_temperature_look_by_city(self): temperature = world.page_info['main']
  • 4. temperatuce_farenhait = temperature['temp'] assert temperatuce_farenhait != "" @step("I ask for weather information by latitude and longitude") def ask_for_weather_information_by_latlong(self): world.url = world.expectedUrl + "?lat=" + world.expectedLatitude + "&lon=" + world.expectedLongitude world.page_info_by_latlon = weather2.getInformation(world.url) @step("I get the temperature look by latitude and longitude") def get_temperature_by_latlong(self): temperature = world.page_info_by_latlon['main'] temperatuce_farenhait = temperature['temp'] assert temperatuce_farenhait != ""