Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansurf committed May 31, 2024
1 parent e37fef8 commit 540b685
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ def run(lat=0, long=0):
helper.print_outputs(
city, ocean_data_dict, arguments, gpt_prompt, gpt_info
)
return ocean_data_dict
else:
# print the output in json format!
helper.json_output(ocean_data_dict)
json_output = helper.json_output(ocean_data_dict)
return json_output


if __name__ == "__main__":
Expand Down
47 changes: 46 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
Run pytest: pytest
"""

from src.api import get_coordinates, get_uv, ocean_information
from src.api import (
forecast,
gather_data,
get_coordinates,
get_uv,
ocean_information,
seperate_args_and_get_location,
)
from src.helper import arguments_dictionary


def test_get_coordinates():
Expand All @@ -25,3 +33,40 @@ def test_ocean_information():
assert isinstance(ocean[0], (int, float))
assert isinstance(ocean[1], (int, float))
assert isinstance(ocean[2], (int, float))


def test_forecast():
"""
Test forecast() at an arbitrary location(palm beach),
ensures it returns 7 days of heights/directions/periods
"""
len_of_forecast_list = 7
fc = forecast(26.705, -80.036, 1, 7)
heights, directions, periods = fc[0], fc[1], fc[2]
assert len(heights) == len_of_forecast_list
assert len(directions) == len_of_forecast_list
assert len(periods) == len_of_forecast_list


def test_gather_data():
"""
Gather data needs the arguments dictionary as input,
so we will get this by calling arguments_dictionary()
from helper.py with arbitrary arguments
"""
lat = 33.37
long = -117.57
arguments = arguments_dictionary(lat, long, "San Clemente", [])
ocean_data_dict = gather_data(lat, long, arguments)
assert ocean_data_dict["Location"] == "San Clemente"
assert ocean_data_dict["Lat"] == lat
assert ocean_data_dict["Long"] == long


def test_seperate_args_and_get_location():
"""
Test with an abritrary location
"""
location = ["location=pleasure_point_california"]
location_data = seperate_args_and_get_location(location)
assert "Santa Cruz County" in location_data["city"][0]
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def test_cli_output():
Main() returns a dictionary of: location, height, period, etc.
This functions checks if the dictionary is returned and is populated
"""
expected = 5
# Hardcode lat and long for location.
# If not, when test are ran in Github Actions
# We get an error(because server probably isn't near ocean)
expected = 5
data_dict = cli.run(36.95, -121.97)
time.sleep(5)
assert len(data_dict) >= expected
5 changes: 5 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
QA tests for server.py
Make sure pytest is installed: pip install pytest
Run pytest: pytest
"""

1 comment on commit 540b685

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src
   __init__.py00100% 
   api.py86693%30, 48, 70–71, 103–104
   art.py9367%24–25, 37
   cli.py23483%34, 50–51, 55
   gpt.py10640%16–21, 32–45
   helper.py1435264%50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 81, 92–96, 129–137, 149, 162–163, 181–183, 193, 195–196, 218–219, 256–266, 273–281
   send_email.py24240%5–48
   server.py41410%5–82
   settings.py220100% 
TOTAL35813662% 

Tests Skipped Failures Errors Time
9 0 💤 0 ❌ 0 🔥 13.610s ⏱️

Please sign in to comment.