Skip to content

Commit

Permalink
exclude all the tests by default, update readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kociamber committed Jul 10, 2024
1 parent eb25df7 commit 2938de5
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ ExOwm utilizes some cool features such as:

Each location entry in the list spawns a separate task (Elixir worker process) to check whether the request has been made within a specified time interval. If it has, the result is fetched from the cache. Otherwise, an API query is sent, the result is cached, and the data is returned.

## Running local tests

Since all the tests are based on OWM API calls, they are disabled by default. To enable them, please remove `:api_based_test` from the `test/test_helper.exs file`.

## To do

* Add remaining OWM APIs (including One Call API 3.0)
Expand Down
18 changes: 15 additions & 3 deletions test/get_current_weather_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ defmodule GetCurrentWeatherTest do
:ok
end

test ":get_current_weather/1 with a city name" do
@tag :api_based_test
test "get_current_weather/1 with a city name" do
result = ExOwm.get_current_weather(%{city: "Bengaluru"})
assert result != []

Expand All @@ -17,7 +18,8 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Bengaluru"
end

test ":get_current_weather/1 with a list of cities" do
@tag :api_based_test
test "get_current_weather/1 with a list of cities" do
result = ExOwm.get_current_weather([%{city: "Lucerne"}])

assert is_list(result)
Expand All @@ -29,6 +31,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Lucerne"
end

@tag :api_based_test
test "get_current_weather/1 with a city name and a country code" do
result = ExOwm.get_current_weather([%{city: "Munich", countr_code: "de"}])

Expand All @@ -41,7 +44,8 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Munich"
end

test ":get_current_weather/1 with a city id" do
@tag :api_based_test
test "get_current_weather/1 with a city id" do
result = ExOwm.get_current_weather([%{id: 2_759_794}])

assert is_list(result)
Expand All @@ -52,6 +56,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Amsterdam" or "Gemeente Amsterdam"
end

@tag :api_based_test
test "get_current_weather/1 with a latitude and a longitude" do
result = ExOwm.get_current_weather([%{lat: 52.374031, lon: 4.88969}])

Expand All @@ -64,6 +69,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Amsterdam" or "Gemeente Amsterdam"
end

@tag :api_based_test
test "get_current_weather/1 with a zip and a country code" do
result = ExOwm.get_current_weather([%{zip: "94040", country_code: "us"}])

Expand All @@ -76,6 +82,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Mountain View"
end

@tag :api_based_test
test "get_current_weather/1 with a city name and options" do
city = %{city: "Warsaw"}
options = [units: :metric, lang: :pl]
Expand All @@ -91,6 +98,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Warszawa"
end

@tag :api_based_test
test "get_current_weather/1 with a city name and a country code and options" do
city = %{city: "Warsaw", countr_code: "pl"}
options = [units: :metric, lang: :pl]
Expand All @@ -106,6 +114,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Warszawa"
end

@tag :api_based_test
test "get_current_weather/1 with a city id and options" do
city = %{id: 2_759_794}
options = [units: :metric, lang: :pl]
Expand All @@ -121,6 +130,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Amsterdam" or "Gemeente Amsterdam"
end

@tag :api_based_test
test "get_current_weather/1 with a latitude and a longitude and options" do
city = %{lat: 52.374031, lon: 4.88969}
options = [units: :metric, lang: :pl]
Expand All @@ -136,6 +146,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Amsterdam" or "Gemeente Amsterdam"
end

@tag :api_based_test
test "get_current_weather/1 with a zip code, a country code and options" do
city = %{zip: "94040", country_code: "us"}
options = [units: :metric, lang: :pl]
Expand All @@ -151,6 +162,7 @@ defmodule GetCurrentWeatherTest do
assert Map.get(map, "name") == "Mountain View"
end

@tag :api_based_test
test "get_current_weather/1 with non-existing city" do
result = ExOwm.get_current_weather(%{city: "Bonkersville"})

Expand Down
11 changes: 11 additions & 0 deletions test/get_five_day_forecast_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule GetFiveDayForecastTest do
:ok
end

@tag :api_based_test
test "get_five_day_forecast/1 with a single city" do
result = ExOwm.get_five_day_forecast(%{city: "Sochi"})

Expand All @@ -25,6 +26,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Sochi"
end

@tag :api_based_test
test "get_five_day_forecast/1 with city a list of cities" do
result = ExOwm.get_five_day_forecast([%{city: "Sochi"}])

Expand All @@ -43,6 +45,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Sochi"
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of cities and country codes" do
result = ExOwm.get_five_day_forecast([%{city: "Warsaw", countr_code: "pl"}])

Expand All @@ -61,6 +64,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Warsaw"
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of city ids" do
result = ExOwm.get_five_day_forecast([%{id: 2_759_794}])

Expand All @@ -79,6 +83,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Amsterdam"
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of latitudes and longitudes" do
result = ExOwm.get_five_day_forecast([%{lat: 4.3942822222, lon: 18.558442503}])

Expand All @@ -97,6 +102,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Kolongo"
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of zip codes and country codes" do
result = ExOwm.get_five_day_forecast([%{zip: "94040", country_code: "us"}])

Expand All @@ -115,6 +121,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Mountain View"
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of city names and options" do
result = ExOwm.get_five_day_forecast([%{city: "Zurich"}], units: :metric, lang: :ch)

Expand All @@ -134,6 +141,7 @@ defmodule GetFiveDayForecastTest do
end

# Fribourg or Freiburg is a city which exists in multiple countries
@tag :api_based_test
test "get_five_day_forecast/1 with a list of city names, country codes and options" do
result =
ExOwm.get_five_day_forecast([%{city: "Freiburg", countr_code: "ch"}],
Expand All @@ -157,6 +165,7 @@ defmodule GetFiveDayForecastTest do
assert %{"city" => %{"country" => "CH"}} = map
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of city ids and options" do
result = ExOwm.get_five_day_forecast([%{id: 2_759_794}], units: :metric, lang: :pl)

Expand All @@ -175,6 +184,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Amsterdam"
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of latitudes, longitudes and options" do
result =
ExOwm.get_five_day_forecast([%{lat: 52.374031, lon: 4.88969}], units: :metric, lang: :pl)
Expand All @@ -194,6 +204,7 @@ defmodule GetFiveDayForecastTest do
assert city_name == "Amsterdam"
end

@tag :api_based_test
test "get_five_day_forecast/1 with a list of zip codes, country codes and options" do
result =
ExOwm.get_five_day_forecast([%{zip: "94040", country_code: "us"}],
Expand Down
3 changes: 3 additions & 0 deletions test/get_historical_weather_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule GetHistoricalWeatherTest do
:ok
end

@tag :api_based_test
test "get_historical_weather/1 with a list of latitudes and longitudes" do
yesterday =
DateTime.utc_now() |> DateTime.add(24 * 60 * 60 * -1, :second) |> DateTime.to_unix()
Expand All @@ -24,6 +25,7 @@ defmodule GetHistoricalWeatherTest do
assert Map.get(map, "hourly") |> Enum.count() == 24
end

@tag :api_based_test
test "get_historical_weather/2 with a list of latitudes and longitudes and options" do
yesterday =
DateTime.utc_now() |> DateTime.add(24 * 60 * 60 * -1, :second) |> DateTime.to_unix()
Expand All @@ -46,6 +48,7 @@ defmodule GetHistoricalWeatherTest do
assert Map.get(map, "hourly") |> List.first() |> Map.get("dt") < yesterday
end

@tag :api_based_test
test "get_historical_weather/2 with an incorrect coordinates" do
city = %{lat: "15", lon: "-2", dt: -200}

Expand Down
11 changes: 11 additions & 0 deletions test/get_hourly_forecast_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule GetHourlyForecastTest do
:ok
end

@tag :api_based_test
test "get_hourly_forecast/1 with a city name" do
result = ExOwm.get_hourly_forecast(%{city: "Sochi"})

Expand All @@ -25,6 +26,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Sochi"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of cities" do
result = ExOwm.get_hourly_forecast([%{city: "Sochi"}])

Expand All @@ -43,6 +45,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Sochi"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of cities and country codes" do
city = %{city: "Warsaw", countr_code: "pl"}

Expand All @@ -63,6 +66,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Warsaw"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of city ids" do
result = ExOwm.get_hourly_forecast([%{id: 2_759_794}])

Expand All @@ -81,6 +85,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Amsterdam"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of coordinates" do
result = ExOwm.get_hourly_forecast([%{lat: 4.3942822222, lon: 18.558442503}])

Expand All @@ -100,6 +105,7 @@ defmodule GetHourlyForecastTest do
assert map |> Map.get("list") |> Enum.count() == 96
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of zip codes and country codes" do
result = ExOwm.get_hourly_forecast([%{zip: "94040", country_code: "us"}])

Expand All @@ -118,6 +124,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Mountain View"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of cities and options" do
result = ExOwm.get_hourly_forecast([%{city: "Zurich"}], units: :metric, lang: :ch)

Expand All @@ -136,6 +143,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Zurich"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of cities, country codes and options" do
result =
ExOwm.get_hourly_forecast([%{city: "Freiburg", countr_code: "ch"}],
Expand All @@ -160,6 +168,7 @@ defmodule GetHourlyForecastTest do
assert %{"city" => %{"country" => "CH"}} = map
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of city ids and options" do
result = ExOwm.get_hourly_forecast([%{id: 2_759_794}], units: :metric, lang: :pl)

Expand All @@ -178,6 +187,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Amsterdam"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of coordinates and options" do
result =
ExOwm.get_hourly_forecast([%{lat: 52.374031, lon: 4.88969}], units: :metric, lang: :pl)
Expand All @@ -197,6 +207,7 @@ defmodule GetHourlyForecastTest do
assert city_name == "Amsterdam"
end

@tag :api_based_test
test "get_hourly_forecast/1 with a list of zip codes, country codes and options" do
result =
ExOwm.get_hourly_forecast([%{zip: "94040", country_code: "us"}], units: :metric, lang: :pl)
Expand Down
3 changes: 3 additions & 0 deletions test/get_one_call_weather_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule GetOneCallWeatherTest do
:ok
end

@tag :api_based_test
test "get_weather/1 with a list of coordinates" do
result = ExOwm.get_weather([%{lat: 52.374031, lon: 4.88969}])

Expand All @@ -20,6 +21,7 @@ defmodule GetOneCallWeatherTest do
assert Map.get(map, "current") |> Map.get("temp") > 200
end

@tag :api_based_test
test "get_weather/1 with a list of coordinates and options" do
city = %{lat: 46.514098, lon: 8.326755}
options = [units: :metric, lang: :ru]
Expand All @@ -36,6 +38,7 @@ defmodule GetOneCallWeatherTest do
assert Map.get(map, "current") |> Map.get("temp") < 100
end

@tag :api_based_test
test "get_weather/1 with an incorrect coordinates" do
city = %{lat: "800", lon: "-2"}

Expand Down
Loading

0 comments on commit 2938de5

Please sign in to comment.