Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansurf committed May 25, 2024
1 parent 130465a commit ef5161c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
33 changes: 19 additions & 14 deletions src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,32 @@
if "metric" in args or "m" in args:
ocean["unit"] = "metric"

# Calls APIs though python files
ocean_data = api.ocean_information(lat, long, ocean["decimal"], ocean["unit"])
uv_index = api.get_uv(lat, long, ocean["decimal"], ocean["unit"])
def gather_data(lat=lat, long=long):
# Calls APIs though python files
ocean_data = api.ocean_information(lat, long, ocean["decimal"], ocean["unit"])
uv_index = api.get_uv(lat, long, ocean["decimal"], ocean["unit"])

ocean["ocean_data"] = ocean_data
ocean["uv_index"] = uv_index
ocean["ocean_data"] = ocean_data
ocean["uv_index"] = uv_index

data_dict = {
"Location : ": city,
"Height: ": ocean_data[0],
"Direction: ": ocean_data[1],
"Period: ": ocean_data[2],
"UV Index: ": uv_index,
}
data_dict = {
"Location : ": city,
"Height: ": ocean_data[0],
"Direction: ": ocean_data[1],
"Period: ": ocean_data[2],
"UV Index: ": uv_index,
}
return ocean_data, uv_index, data_dict


def main():
def main(lat=lat, long=long):
"""
Main function
"""
data = gather_data()
ocean_data = data[0]
uv_index = data[1]
data_dict = data[2]
print("\n")
if coordinates == "No data":
print("No location found")
Expand All @@ -99,5 +105,4 @@ def main():
helper.print_forecast(ocean, forecast)
return data_dict


main()
7 changes: 1 addition & 6 deletions src/tests/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@

sys.path.append("../backend")

import unittest
from unittest.mock import patch
import io
import threading
import requests
import time
import subprocess
import os
from main import main
from helper import extract_decimal
from api import get_coordinates, get_uv, ocean_information
Expand Down Expand Up @@ -61,6 +56,6 @@ def test_main():
Main() returns a dictionary of: location, height, period, etc.
This functions checks if the dictionary is returned and is populated
"""
data_dict = main()
data_dict = main(36.95, -122.02)
time.sleep(5)
assert len(data_dict) >= 5

0 comments on commit ef5161c

Please sign in to comment.