Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing errors in the logic of requesting measurements to the real server #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rgenius-ru
Copy link

What has been done:

  • Fixed errors in the list() method of the Measurements class in _async and _sync, which caused crashes when calling the list() method without specifying date_from.
  • Fixed the test case for the list() method: checking whether the list() method was called successfully without specifying date_from.

Tests:

All [hatch run test:cov] tests pass successfully.

Why this is important:

These changes allow the list() method of the Measurements class to be used without specifying date_from when querying the real server. Previously, this would result in an error: 500 Internal Server Error.

How to replicate this error:

To test and replicate this error, you can use the following code:

from openaq import OpenAQ
from pprint import pprint
import datetime

client = OpenAQ(api_key='YOUR_API_KEY')

locations = client.locations.list(coordinates=(39.904211,116.407395), radius=10_000)  # Beijin

sensor_id = locations.results[0].sensors[0].id  # id=40 - One from Beijin
sensor = client.sensors.get(sensor_id)

measurements = client.measurements.list(40, limit=100)  # ERROR: "openaq.shared.exceptions.ServerError: Internal Server Error"
pprint(measurements)

client.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant