Skip to content

Commit

Permalink
deleted print code in utils.py
Browse files Browse the repository at this point in the history
added test_useful_info.py
  • Loading branch information
taka-rl committed Oct 18, 2024
1 parent 19f9ccf commit 448b26c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 0 additions & 1 deletion flask_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def get_weather_info(location: str) -> dict[str, Any]:
response = requests.get(url)
if response.status_code == 200:
data = response.json() # Parse the JSON response
print(data)

weather_data = {'temperature': data['main']['temp'],
'max_temperature': data['main']['temp_max'],
Expand Down
31 changes: 31 additions & 0 deletions tests/test_useful_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
def test_access_useful_info_page(super_admin_client):
response = super_admin_client.get('/useful_info')
assert response.status_code == 200
assert b'Useful Information' in response.data
assert b'Currency' in response.data
assert b'Weather' in response.data


def test_currency_api(super_admin_client):
response = super_admin_client.post('/currency')
assert response.status_code == 200
assert b'base_currency' in response.data
assert b'exchange_rate' in response.data
assert b'target_currency' in response.data


# check if I can use API: weather
def test_weather_api(super_admin_client):
response = super_admin_client.post('/weather', data={
'loc': 'Budapest'
})
assert response.status_code == 200
assert b'Weather forecast' in response.data
assert b'Temperature' in response.data
assert b'Max Temperature' in response.data
assert b'Min Temperature' in response.data
assert b'Feels like' in response.data
assert b'Wind Speed' in response.data
assert b'Pressure' in response.data
assert b'Humidity' in response.data
assert b'Description' in response.data

0 comments on commit 448b26c

Please sign in to comment.