Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Lettuce example using simple scenario
1. Lettuce example using simple
scenarios:
El siguienteejemplotienetresarchivos,un feature ydospy.En el siguiente ejemplo
atacaremosla api del tiempoycomprobaremosque ciertosvaloresseancorrectos. Paraello
utilizaremos lettuce conpython. Ademásutilizaremosscenariossimples.
Weather.feature:
Feature:Checkif the weatherservice worksproperly
In orderto check the weatherservice
As beginner
I'll get some valuesandcheckif theyare okand if the temperature giveniscorrect
Scenario:Checkif a cityand a countrygivenare correct
GivenI accessthe url withhttp://api.openweathermap.org/data/2.5/weather
Andthe cityis Londonandthe countryGB
WhenI ask for the cityand country name
ThenI check if the city andcountry are correct
AndI checkif the status code is200
Scenario:Checkif a latitude andlongitudegivenare correct
GivenI accessthe url withhttp://api.openweathermap.org/data/2.5/weather
Andthe latitude is35 and the longitude 139
WhenI ask for the latitude andlongitude
ThenI check if the latitude andlongitude are correct
AndI checkif the status code is200
Scenario:Checkif the temperature iscorrectgivenacity anda country
GivenI accessthe url withhttp://api.openweathermap.org/data/2.5/weather
Andthe cityis Madridand the country ES
WhenI ask for the cityand country name
ThenI get the temperature lookbycityandcountry
Scenario:Checkif the temperature iscorrectgiventhe latitude andlongitude
GivenI accessthe url withhttp://api.openweathermap.org/data/2.5/weather
Andthe latitude is35 and the longitude 139
WhenI ask for weatherinformationbylatitudeandlongitude
ThenI get the temperature lookbylatitude andlongitude
weatherSteps.py:
__author__ = 'kwiznia'
fromlettuce import*
fromweather2import*
fromnose.toolsimport*
2. weather2= weather2()
@step("Iaccessthe url with(.*)")
def access_url(self,expectedUrl):
world.expectedUrl =expectedUrl
assert_regexp_matches(world.expectedUrl,'^http'),"The URL isempty"
@step("the cityis(Madrid|London|Barcelona|Berlin)andthe country(GB|ES|Germany)")
def city_and_country(self,expectedCity,expectedCountry):
world.expectedCity =expectedCity
world.expectedCountry=expectedCountry
@step("Iaskfor the cityand countryname")
def ask_for_city_and_country(self):
world.url = world.expectedUrl +"?q=" + world.expectedCity+","+ world.expectedCountry
world.page_info =weather2.getInformation(world.url)
@step("Icheckif the cityand country are correct")
def check_city_and_country_are_correct(self):
sys = world.page_info['sys']
assertsys != ""
assertworld.expectedCityinworld.page_info['name']
assertworld.expectedCountryinsys['country']
@step("Icheckif the statuscode is200")
def check_status_code(self):
assert_equals(world.response.status_code,200),"page not found"
@step("the latitude is(40|35|41.3|53.2) andthe longitude (-3.7|139|2.1|13.3)")
def check_lat_and_long(self,expectedLatitude,expectedLongitude):
world.expectedLatitude =expectedLatitude
world.expectedLongitude =expectedLongitude
@step("Iaskfor the latitude andlongitude")
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("Icheckif the latitude andlongitudeare correct")
def check_lat_and_long_are_correct(self):
latlon= world.page_info['coord']
assertlatlon['lon'] !=""
assertlatlon['lat'] !=""
assert_equals(int(world.expectedLatitude),latlon['lat'])