diff --git a/.gitignore b/.gitignore index 3ed6cf2..d027e2c 100644 --- a/.gitignore +++ b/.gitignore @@ -159,7 +159,7 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +.idea/ *.cache.sqlite *.pyc \ No newline at end of file diff --git a/src/api.py b/src/api.py index 87b9052..955f80d 100644 --- a/src/api.py +++ b/src/api.py @@ -134,7 +134,7 @@ def get_uv_history(lat, long, decimal, unit="imperial"): "hourly": ["uv_index"], "start_date": formatted_date_one_year_ago, "end_date": formatted_date_one_year_ago, - "timezone": "auto" + "timezone": "auto", } # For testing purposes if testing equals 1 it will continue @@ -246,7 +246,7 @@ def ocean_information_history(lat, long, decimal, unit="imperial"): "length_unit": unit, "timezone": "auto", "start_date": formatted_date_one_year_ago, - "end_date": formatted_date_one_year_ago + "end_date": formatted_date_one_year_ago, } # For testing purposes if testing equals 1 it will continue @@ -276,7 +276,7 @@ def ocean_information_history(lat, long, decimal, unit="imperial"): return [ f"{hourly_wave_height[current_hour]:.{decimal}f}", f"{hourly_wave_direction[current_hour]:.{decimal}f}", - f"{hourly_wave_period[current_hour]:.{decimal}f}" + f"{hourly_wave_period[current_hour]:.{decimal}f}", ] @@ -539,22 +539,24 @@ def gather_data(lat, long, arguments): "Height": ocean_data[0], "Height one year ago": ( ocean_information_history( - lat, long, arguments["decimal"], arguments["unit"])[0] + lat, long, arguments["decimal"], arguments["unit"] + )[0] ), "Swell Direction": ocean_data[1], "Swell Direction one year ago": ( ocean_information_history( - lat, long, arguments["decimal"], arguments["unit"])[1] + lat, long, arguments["decimal"], arguments["unit"] + )[1] ), "Period": ocean_data[2], "Period one year ago": ( ocean_information_history( - lat, long, arguments["decimal"], arguments["unit"])[2] + lat, long, arguments["decimal"], arguments["unit"] + )[2] ), "UV Index": uv_index, "UV Index one year ago": ( - get_uv_history( - lat, long, arguments["decimal"], arguments["unit"]) + get_uv_history(lat, long, arguments["decimal"], arguments["unit"]) ), "Air Temperature": air_temp, "Wind Speed": wind_speed, diff --git a/src/helper.py b/src/helper.py index 38b0388..07a408c 100644 --- a/src/helper.py +++ b/src/helper.py @@ -68,18 +68,22 @@ def set_output_values(args, arguments_dictionary): # noqa "hide_uv": ("show_uv", 0), "huv": ("show_uv", 0), "show_past_uv": ("show_past_uv", 1), + "spuv": ("show_past_uv", 1), "hide_past_uv": ("show_past_uv", 0), "hide_height": ("show_height", 0), "hh": ("show_height", 0), "show_height_history": ("show_height_history", 1), + "shh": ("show_height_history", 1), "hide_height_history": ("show_height_history", 0), "hide_direction": ("show_direction", 0), "hdir": ("show_direction", 0), "show_direction_history": ("show_direction_history", 1), + "sdh": ("show_direction_history", 1), "hide_direction_history": ("show_direction_history", 0), "hide_period": ("show_period", 0), "hp": ("show_period", 0), "show_period_history": ("show_period_history", 1), + "sph": ("show_period_history", 1), "hide_period_history": ("show_period_history", 0), "hide_location": ("show_city", 0), "hl": ("show_city", 0), @@ -163,14 +167,23 @@ def print_ocean_data(arguments_dict, ocean_data_dict): ("show_uv", "UV Index", "UV index: "), ("show_past_uv", "UV Index one year ago", "UV Index one year ago: "), ("show_height", "Height", "Wave Height: "), - ("show_height_history", "Height one year ago", - "Wave Height one year ago: "), + ( + "show_height_history", + "Height one year ago", + "Wave Height one year ago: ", + ), ("show_direction", "Swell Direction", "Wave Direction: "), - ("show_direction_history", "Swell Direction one year ago", - "Wave Direction one year ago: "), + ( + "show_direction_history", + "Swell Direction one year ago", + "Wave Direction one year ago: ", + ), ("show_period", "Period", "Wave Period: "), - ("show_period_history", "Period one year ago", - "Wave Period one year ago:"), + ( + "show_period_history", + "Period one year ago", + "Wave Period one year ago:", + ), ("show_air_temp", "Air Temperature", "Air Temp: "), ("show_wind_speed", "Wind Speed", "Wind Speed: "), ("show_wind_direction", "Wind Direction", "Wind Direction: "), diff --git a/tests/test_api.py b/tests/test_api.py index 82644b6..b4bdcd0 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -3,6 +3,7 @@ Make sure pytest is installed: pip install pytest Run pytest: pytest """ + from unittest.mock import patch import pytest @@ -107,7 +108,7 @@ def test_get_uv_history_invalid_coordinates(): get_uv_history(1000, -2000, 2) -@patch('src.api.testing', new=0) # Set testing variable to 0 +@patch("src.api.testing", new=0) # Set testing variable to 0 def test_get_uv_history_api_response(): """ Test how get_uv_history handles API response. @@ -116,7 +117,7 @@ def test_get_uv_history_api_response(): when called with valid coordinates while patching the API call request. """ result = get_uv_history(31.9505, 115.8605, 1) - expected_result = '0.6' + expected_result = "0.6" assert result == expected_result @@ -158,7 +159,7 @@ def test_ocean_information_history_response_format(): assert len(waves) == expected_wave_count -@patch('src.api.testing', new=0) # Set testing variable to 0 +@patch("src.api.testing", new=0) # Set testing variable to 0 def test_ocean_information_history(): """ Test how ocean_information_history handles API response. @@ -167,5 +168,5 @@ def test_ocean_information_history(): when called with valid coordinates while patching the API call request. """ result = ocean_information_history(31.9505, 115.8605, 1) - expected_result = ['0.6', '0.6', '0.6'] + expected_result = ["0.6", "0.6", "0.6"] assert result == expected_result diff --git a/tests/test_helper.py b/tests/test_helper.py index e9576df..9076939 100644 --- a/tests/test_helper.py +++ b/tests/test_helper.py @@ -127,10 +127,12 @@ def test_set_output_values_hide_period_history(): def test_set_output_values_combined_arguments(): - args = ["show_past_uv", - "show_height_history", - "show_direction_history", - "show_period_history"] + args = [ + "show_past_uv", + "show_height_history", + "show_direction_history", + "show_period_history", + ] arguments_dictionary = {} expected = { "show_past_uv": 1,