This project provides a Python script to fetch and print weather forecasts for a specified city using the WeatherAPI. Additionally, it includes a metamorphic test to check the consistency of weather forecasts for nearby cities.
- Fetches weather forecast for a specified city using WeatherAPI.
 - Prints the weather forecast details including date, average temperature, and condition.
 - Performs a metamorphic test to verify the consistency of forecasts between nearby cities.
 
Prerequisites
- Python 3.x
 
- Clone the repository:
 
git https://github.com/gabrielsants/weather-metamorphic-testing.git
cd weather-metamorphic-testing
- Install the library 
requestswith the prompt:: 
pip install requests
- Get your API key from WeatherAPI and save it in api_key.txt.
 
- Edit 
weather_forecast.pyto specify your city: 
city = "São Paulo"
python weather_forecast.py
python test_metamorphic_weather_forecast.py
We selected a set of nearby cities (São Paulo, Guarulhos and Osasco) to check the consistency of the forecasts.
For each city, we get the weather forecast for the next 3 days using the get_weather_forecast function.
- For each day of the forecast, we compare the average temperatures between the cities.
 - If the temperature difference between the cities is greater than an arbitrary threshold (e.g. 2°C), we report an inconsistency.
 - We also check that the weather conditions (text descriptions) are consistent between the cities. If there is more than one different condition for the same day, we report an inconsistency.
 - We use the 
all_consistentvariable to track whether all forecasts were consistent. 
After checking all the forecast days, we print out a message indicating whether the test passed (consistent forecasts) or failed (inconsistencies found).
Weather forecast for São Paulo:
Date: 2023-05-20, Average Temperature: 22.5°C, Condition: Partly cloudy
Date: 2023-05-21, Average Temperature: 23.0°C, Condition: Sunny
Date: 2023-05-22, Average Temperature: 21.5°C, Condition: Rain
Inconsistency detected in temperatures for day 2: [22.5, 23.0, 21.5]
Inconsistency detected in conditions for day 2: ['Partly cloudy', 'Sunny', 'Rain']
Metamorphic test failed: Inconsistencies found in weather forecasts between nearby cities.
- Busca a previsão do tempo para uma cidade especificada usando a WeatherAPI.
 - Imprime os detalhes da previsão do tempo, incluindo data, temperatura média e condição.
 - Realiza um teste metamórfico para verificar a consistência das previsões entre cidades próximas.
 
Pré-requisitos
- Python 3.x
 
- Clone o repositório:
 
git https://github.com/gabrielsants/weather-metamorphic-testing.git
cd weather-metamorphic-testing
- Instale a biblioteca 
requestscom o comando: 
pip install requests
- Obtenha sua chave da API em WeatherAPI e salve-a no arquivo api_key.txt.
 
- Edite 
weather_forecast.pypara especificar sua cidade: 
city = "São Paulo"
python weather_forecast.py
python test_metamorphic_weather_forecast.py
Selecionamos um conjunto de cidades próximas (São Paulo, Guarulhos e Osasco) para verificar a consistência das previsões.
Para cada cidade, obtemos a previsão do tempo para os próximos 3 dias usando a função get_weather_forecast.
- Para cada dia da previsão, comparamos as temperaturas médias entre as cidades.
 - Se a diferença de temperatura entre as cidades for maior que um limite arbitrário (por exemplo, 2°C), relatamos uma inconsistência.
 - Também verificamos se as condições meteorológicas (descrições de texto) são consistentes entre as cidades. Se houver mais de uma condição diferente para o mesmo dia, relatamos uma inconsistência.
 - Usamos a variável 
all_consistentpara acompanhar se todas as previsões foram consistentes. 
Após verificar todos os dias de previsão, imprimimos uma mensagem indicando se o teste foi aprovado (previsões consistentes) ou reprovado (inconsistências encontradas).
Weather forecast for São Paulo:
Date: 2023-05-20, Average Temperature: 22.5°C, Condition: Partly cloudy
Date: 2023-05-21, Average Temperature: 23.0°C, Condition: Sunny
Date: 2023-05-22, Average Temperature: 21.5°C, Condition: Rain
Inconsistency detected in temperatures for day 2: [22.5, 23.0, 21.5]
Inconsistency detected in conditions for day 2: ['Partly cloudy', 'Sunny', 'Rain']
Metamorphic test failed: Inconsistencies found in weather forecasts between nearby cities.