Open peterdudfield opened 9 months ago
Hi @peterdudfield Sir, I tried to attempt this issue but after running this " poetry run uvicorn pv_site_api.main:app --reload" but it shows API under construction.
Not able to run pytest
poetry run uvicorn pv_site_api.main:app --reload
starts the app up.
Can you run pytest
seperate? What error do you get?
Yes @peterdudfield sir, by running pytest separately test passes ( by keeping the pv_site_api in root directory of tests) . I have questions:
I understand this is a bit tricky
Hi @peterdudfield sir, this is how the output of the forecast looks like
: The forecast value is : [SiteForecastValues(target_datetime_utc=datetime.datetime(2024, 3, 23, 10, 54, 53, 391262), expected_generation_kw=0.0), SiteForecastValues(target_datetime_utc=datetime.datetime(2024, 3, 23, 11, 4, 53, 391262), expected_generation_kw=0.0), SiteForecastValues(target_datetime_utc=datetime.datetime(2024, 3, 23, 11, 14, 53, 391262), expected_generation_kw=0.0), SiteForecastValues(target_datetime_utc=datetime.datetime(2024, 3, 23, 11, 24, 53, 391262), expected_generation_kw=0.0),
how it should look like if returned as percentage. And also while running pytest terminal is getting filed with warnings of DeprecationWarning do we need to update it ?
Warnings would be good to get rid of
I'm surprised all those results are zero?
yes because I am not able to run this command: poetry run pytest tests
: The issue with this is :
2024-03-24 10:31:57 2024-03-24 05:01:57.365 UTC [1] LOG: database system is ready to accept connections 2024-03-24 10:33:12 2024-03-24 05:03:12.916 UTC [71] LOG: invalid length of startup packet 2024-03-24 10:33:13 2024-03-24 05:03:13.978 UTC [72] LOG: invalid length of startup packet 2024-03-24 10:33:13 2024-03-24 05:03:13.982 UTC [73] LOG: invalid length of startup packet 2024-03-24 10:33:13 2024-03-24 05:03:13.991 UTC [74] LOG: invalid length of startup packet 2024-03-24 10:33:15 2024-03-24 05:03:15.726 UTC [75] LOG: invalid length of startup packet 2024-03-24 10:31:57 2024-03-24 05:01:57.211 UTC [49] LOG: database system is shut down
and when I am manually running it using pytest only in the test folder then all tests pass except
: def test_get_status(client, statuses):
response = client.get("/api_status")
assert response.status_code == 200
returned_status = PVSiteAPIStatus(**response.json())
> assert returned_status.status == "my_status 1"
E AssertionError: assert 'my_status 0' == 'my_status 1'
E
E - my_status 1
E ? ^
E + my_status 0
E ? ^
test_status.py:20: AssertionError
because it can't connect to the database, is there something that I am doing wrong while running?
INFO: Will watch for changes in these directories: ['D:\\openclimate\\pv_site\\pv-site-api']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [2444] using WatchFiles
Could not parse SQLAlchemy URL from string 'not_set'
Could not connect to database
INFO: Started server process [1576]
INFO: Waiting for application startup.
INFO: Application startup complete.
@peterdudfield Sir removed 3 warnings please check. #152
@peterdudfield sir corrected format and new PR #153 please check.
sir, how should I proceed with the return forecast as % issue? as all values are zero .
yes because I am not able to run this command:
poetry run pytest tests
: The issue with this is :2024-03-24 10:31:57 2024-03-24 05:01:57.365 UTC [1] LOG: database system is ready to accept connections 2024-03-24 10:33:12 2024-03-24 05:03:12.916 UTC [71] LOG: invalid length of startup packet 2024-03-24 10:33:13 2024-03-24 05:03:13.978 UTC [72] LOG: invalid length of startup packet 2024-03-24 10:33:13 2024-03-24 05:03:13.982 UTC [73] LOG: invalid length of startup packet 2024-03-24 10:33:13 2024-03-24 05:03:13.991 UTC [74] LOG: invalid length of startup packet 2024-03-24 10:33:15 2024-03-24 05:03:15.726 UTC [75] LOG: invalid length of startup packet 2024-03-24 10:31:57 2024-03-24 05:01:57.211 UTC [49] LOG: database system is shut down
and when I am manually running it using pytest only in the test folder then all tests pass except
: def test_get_status(client, statuses): response = client.get("/api_status") assert response.status_code == 200 returned_status = PVSiteAPIStatus(**response.json()) > assert returned_status.status == "my_status 1" E AssertionError: assert 'my_status 0' == 'my_status 1' E E - my_status 1 E ? ^ E + my_status 0 E ? ^ test_status.py:20: AssertionError
because it can't connect to the database, is there something that I am doing wrong while running?
INFO: Will watch for changes in these directories: ['D:\\openclimate\\pv_site\\pv-site-api'] INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [2444] using WatchFiles Could not parse SQLAlchemy URL from string 'not_set' Could not connect to database INFO: Started server process [1576] INFO: Waiting for application startup. INFO: Application startup complete.
pytest will run independently of the database, so you should be able to run them still
Return forecast as % of the site capacity
Context
Possible Implementation
add bool option to
normalize
data by site capacity. Default should be false. This could be donehereThis can be done with python loops, but I wonder if there is a way to do this more efficiently