Closed ryansurf closed 3 months ago
Coverage Report
File Stmts Miss Cover Missing src __init__.py 0 0 100% api.py 119 7 94% 32–36, 54, 76–77, 109–110 art.py 9 3 67% 24–25, 28 cli.py 25 0 100% dev_streamlit.py 37 37 0% 1–86 gpt.py 10 6 40% 16–21, 32–45 helper.py 124 38 69% 110, 121–125, 201–209, 221, 234–235, 266, 268–269, 292–293, 356–366, 373–381 send_email.py 24 24 0% 5–48 server.py 47 10 79% 55, 68–71, 87–91, 103–105 settings.py 22 0 100% streamlit_helper.py 33 33 0% 5–90 TOTAL 450 158 65%
Tests | Skipped | Failures | Errors | Time |
---|---|---|---|---|
11 | 0 :zzz: | 0 :x: | 0 :fire: | 21.077s :stopwatch: |
This pull request focuses on refactoring the code for better readability, maintainability, and consistency. Key changes include updating docstrings, using dictionaries and lists for argument mappings, and modifying return types. Additionally, tests have been added and updated to validate the new implementations.
Files | Changes |
---|---|
src/helper.py src/api.py |
Refactored functions to improve readability and maintainability by using dictionaries and lists for mappings, and updated return types for consistency. |
tests/test_helper.py tests/test_api.py |
Added and updated tests to validate the new implementations and ensure correctness of JSON output and forecast data. |
@ryansurf I'll be reviewing it tonight, so hold on a bit!
@ryansurf I'll be reviewing it tonight, so hold on a bit!
No rush!
Hello @K-dash !
This PR mostly cleans up
helper.py
. Addresses https://github.com/ryansurf/cli-surf/issues/84Changes
src/api.py
Mostly organizing code.
forecast()
now returns a dictionary, not several nested lists, for reusabilitysrc/helper.py
if
statements. These were replaced by dictionary mappings, which makes the code look cleaner.forecast_to_json
was altered to take a dictionary as input, from theforecast()
function insrc/api.py
src/test_api.py
test_forecast()
was failing because of the dictionary now being returned from the forecast. Fixed thissrc/test_helper.py
A new unit test was added to test the json argument. Prior to this, the json argument was causing an error and we were non-the-wiser because our tests didn't catch this!
Summary by Sourcery
Refactor helper functions to use mappings for setting and printing argument values, update forecast data handling to use dictionaries, and enhance test coverage to validate these changes.
Enhancements:
set_output_values
to use a mapping dictionary for setting argument values.print_ocean_data
andprint_forecast
to use mapping lists for printing data.forecast_to_json
to handle forecast data as a dictionary instead of a list.print_outputs
function to handle ocean data dictionary more effectively.Tests:
test_json_output
to verify JSON output structure and data types.test_forecast
to validate the new dictionary-based forecast data structure.