Skip to content

Commit

Permalink
Run formatter and make final adjustment to aruments as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AITMAR-TAFE committed Nov 9, 2024
1 parent 8e735bc commit 1bc944a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 10 additions & 8 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}",
]


Expand Down Expand Up @@ -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,
Expand Down
25 changes: 19 additions & 6 deletions src/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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: "),
Expand Down
9 changes: 5 additions & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Make sure pytest is installed: pip install pytest
Run pytest: pytest
"""

from unittest.mock import patch

import pytest
Expand Down Expand Up @@ -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.
Expand All @@ -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


Expand Down Expand Up @@ -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.
Expand All @@ -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
10 changes: 6 additions & 4 deletions tests/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1bc944a

Please sign in to comment.