/robotframework-openweathermap

A collection of Robot Framework keywords for the OpenWeatherMap library which allows you to request weather data

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

robotframework-openweathermap

License: GPL v3 Code style: black CodeQL PyPi version

robotframework-openweathermap is a Robot Framework keyword collection for the OpenWeatherMap API.

Installation

The easiest way is to install this package is from pypi:

pip install robotframework-openweathermap

Robot Framework Library Examples

Prerequisites:

The accompanying Robot Framework test file relies on two requirements:

  • get an OpenWeatherMap API key (it's free)
  • create an environment variable OWM_API_KEY and assign the OpenWeatherMap API key to that variable
  • Execute test with robot keyword_checks.robot

Library usage and supported keywords

Default settings

The following rules apply:

  • The default value for each parameter is None
  • Each parameter supports Getter and Setter keywords, e.g, Set OpenWeatherMap Latitude
  • Each OpenWeatherMap Keyword also permits the usage of these parameters. Example:
Get Current Weather   latitude=....
  • A keyword's parameter value has priority over the Setter value. This means that if you use Set OpenWeathermap Latitude 10 and Get Current Weather latitude=20, the value from the OWK Keyword will supersede the Setter keyword and a value of 20 is going to be used.

Options for setting the parameter values

You can either specify all parameters during the initial setup of the library or alternatively via separate keywords

Option 1 - set as position parameters

*** Settings ***

Library  OpenWeatherMapLibrary  51.82798  9.4455  ...

*** Test Cases ***
My first test case

Option 2 - set as named parameters

*** Settings ***

Library  OpenWeatherMapLibrary  latitude=51.82798  longitude=9.4455  ...

*** Test Cases ***
My first test case

Option 3 - Use Robot Keywords

Set OpenWeatherMap Latitude   latitude=51.82798

Generic Getter / Setter Robot Keywords supported by this library

You can use these optional Getter/Setter methods for setting your fixed default values. If you specify the same parameter as part of the actual OpenWeatherMap keyword, the value specified with that API call supersedes these generic Getter/Setter values.

Keyword Description Arguments Valid Values
Get/Set OpenWeatherMap Latitude Gets / Sets the latitude value latitude float value
Get/Set OpenWeatherMap Longitude Gets / Sets the longitude value longitude float value
Get/Set OpenWeatherMap API Key Gets / Sets the OWM API Key apikey string
Get/Set OpenWeatherMap Number Of Results Gets / Sets the max number of results number integer > 0
Get/Set OpenWeatherMap Language Gets / Sets the desired output language language see OpenWeatherMap API
for valid values
Get/Set OpenWeatherMap Excludes Gets / Sets the exclude(s) value.
Separarate multiple values with a comma
See API documentation for details
exclude current
minutely
hourly
daily
alerts
Get/Set OpenWeatherMap Output Format Gets / Sets the output format (e.g. json) output_format json
xml
html
Get/Set OpenWeatherMap Unit Format Gets / Sets the unit format
See API Documentation for details
Format availability depends on API call
unit_format standard
metric
imperial
Get/Set OpenWeatherMap Datetime Start Gets / Sets the start datetime for date ranges dt_start Unix timestamp
Get/Set OpenWeatherMap Datetime End Gets / Sets the end datetime for date ranges dt_end Unix timestamp
Get/Set OpenWeatherMap Datetime Gets / Sets a single point in time dt Unix Timestamp

OpenWeatherMap Keywords

Please note that a majority of these keywords requires a paid OpenWeatherMap subscription. You can still try to run the keywords but most of them will fail with a http 4xx error unless you have a valid paid subscription.

Each of the following keywords has a set of mandatory parameters. which means that if you used the setter methods to assign values for latitude and longitude, for example, you can omit those values for the following keywords.

Keyword Description Mandatory
parameters
Optional
parameters
Comments
Get Current Weather Access current weather data for any location on
Earth including over 200,000 cities
latitude
longitude
apikey
output_format
unit_format
language
Get Hourly Forecast 4 Days Hourly forecast for 4 days (96 timestamps) latitude
longitude
apikey
output_format
number
language
no output_format
support for HTML
Get OneCall Forecast Current and forecast weather data latitude
longitude
apikey
exclude
unit_format
language
Get Daily Forecasts 16 Days Daily Forecast 16 Days is available at any location on the globe. latitude
longitude
apikey
number
unit_format
output_format
language
no output_format
support for HTML
Get Climatic Forecasts 30 Days Climate Forecast 30 Days allows you to request daily weather data for the next 30 days latitude
longitude
apikey
number
unit_format
output_format
language
no output_format
support for HTML
Get Current Solar Radiation Current solar radiation data latitude
longitude
apikey
Get Solar Radiation Forecast Forecast solar radiation data latitude
longitude
apikey
Get Solar Radiation History Historical solar radiation data
for a from-to time span
latitude
longitude
apikey
dt_start
dt_end
Get 5 Day 3 Hour Forecast 5 day forecast is available at any location on the globe latitude
longitude
apikey
number
unit_format
output_format
language
no output_format
support for HTML
Get Current Air Pollution Radiation Current air pollution data latitude
longitude
apikey
Get Air Pollution Forecast Air pollution data forecast latitude
longitude
apikey
Get Air Pollution History Historical Air Pollution data
for a from-to time span
latitude
longitude
apikey
dt_start
dt_end
Get Road Risk Data Road Risk API provides weather data
and national alerts at the point of
destination and along a route
latitude
longitude
apikey
dt

Known issues

  • Not all OpenWeatherMap APIs have been assigned with corresponding Robot Framework keywords. What you see is what you get - at least for this version.
  • The Get Road Risk Data keyword only supports a single set of latitude and longitude values (the underlying API supports multiple sets)