Skip to content

Commit 663f4ce

Browse files
committed
MOD: Rename get_dataset_condition endpoint
1 parent e89727f commit 663f4ce

File tree

2 files changed

+71
-71
lines changed

2 files changed

+71
-71
lines changed

databento/historical/api/metadata.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -81,46 +81,6 @@ def list_datasets(
8181
)
8282
return response.json()
8383

84-
def list_dataset_conditions(
85-
self,
86-
dataset: Union[Dataset, str],
87-
start_date: Union[date, str],
88-
end_date: Union[date, str],
89-
) -> Dict[str, Any]:
90-
"""
91-
Request the dataset conditions per date from Databento.
92-
93-
Makes a `GET /metadata.list_dataset_conditions` HTTP request.
94-
95-
Use this method to discover data availability and qualility.
96-
97-
Parameters
98-
----------
99-
dataset : Dataset or str
100-
The dataset code (string identifier) for the request.
101-
start_date : date or str
102-
The start date (UTC) for the request range.
103-
end_date : date or str
104-
The end date (UTC) for the request range.
105-
106-
Returns
107-
-------
108-
Dict[str, Any]
109-
110-
"""
111-
params: List[Tuple[str, Optional[str]]] = [
112-
("dataset", enum_or_str_uppercase(dataset, "dataset")),
113-
("start_date", str(pd.to_datetime(start_date).date())),
114-
("end_date", str(pd.to_datetime(end_date).date())),
115-
]
116-
117-
response: Response = self._get(
118-
url=self._base_url + ".list_dataset_conditions",
119-
params=params,
120-
basic_auth=True,
121-
)
122-
return response.json()
123-
12484
def list_schemas(
12585
self,
12686
dataset: Optional[Union[Dataset, str]] = None,
@@ -281,6 +241,46 @@ def list_unit_prices(
281241
)
282242
return response.json()
283243

244+
def get_dataset_condition(
245+
self,
246+
dataset: Union[Dataset, str],
247+
start_date: Union[date, str],
248+
end_date: Union[date, str],
249+
) -> Dict[str, Any]:
250+
"""
251+
Get the dataset condition from Databento.
252+
253+
Makes a `GET /metadata.get_dataset_condition` HTTP request.
254+
255+
Use this method to discover data availability and qualility.
256+
257+
Parameters
258+
----------
259+
dataset : Dataset or str
260+
The dataset code (string identifier) for the request.
261+
start_date : date or str
262+
The start date (UTC) for the request range.
263+
end_date : date or str
264+
The end date (UTC) for the request range.
265+
266+
Returns
267+
-------
268+
Dict[str, Any]
269+
270+
"""
271+
params: List[Tuple[str, Optional[str]]] = [
272+
("dataset", enum_or_str_uppercase(dataset, "dataset")),
273+
("start_date", str(pd.to_datetime(start_date).date())),
274+
("end_date", str(pd.to_datetime(end_date).date())),
275+
]
276+
277+
response: Response = self._get(
278+
url=self._base_url + ".get_dataset_condition",
279+
params=params,
280+
basic_auth=True,
281+
)
282+
return response.json()
283+
284284
def get_record_count(
285285
self,
286286
dataset: Union[Dataset, str],

tests/test_historical_metadata.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -64,37 +64,6 @@ def test_list_datasets_sends_expected_request(self, mocker: MockerFixture) -> No
6464
assert call["timeout"] == (100, 100)
6565
assert isinstance(call["auth"], requests.auth.HTTPBasicAuth)
6666

67-
@pytest.mark.skipif(sys.version_info < (3, 8), reason="incompatible mocking")
68-
def test_list_dataset_conditions_sends_expected_request(
69-
self, mocker: MockerFixture
70-
) -> None:
71-
# Arrange
72-
mocked_get = mocker.patch("requests.get")
73-
74-
# Act
75-
self.client.metadata.list_dataset_conditions(
76-
dataset="GLBX.MDP3",
77-
start_date="2018-01-01",
78-
end_date="2020-01-01",
79-
)
80-
81-
# Assert
82-
call = mocked_get.call_args.kwargs
83-
assert (
84-
call["url"]
85-
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.list_dataset_conditions" # noqa
86-
)
87-
assert ("dataset", "GLBX.MDP3") in call["params"]
88-
assert ("start_date", "2018-01-01") in call["params"]
89-
assert ("end_date", "2020-01-01") in call["params"]
90-
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
91-
assert call["headers"]["accept"] == "application/json"
92-
assert all(
93-
v in call["headers"]["user-agent"] for v in ("Databento/", "Python/")
94-
)
95-
assert call["timeout"] == (100, 100)
96-
assert isinstance(call["auth"], requests.auth.HTTPBasicAuth)
97-
9867
@pytest.mark.skipif(sys.version_info < (3, 8), reason="incompatible mocking")
9968
def test_list_schemas_sends_expected_request(self, mocker: MockerFixture) -> None:
10069
# Arrange
@@ -243,6 +212,37 @@ def test_list_unit_price_sends_expected_request(
243212
assert call["timeout"] == (100, 100)
244213
assert isinstance(call["auth"], requests.auth.HTTPBasicAuth)
245214

215+
@pytest.mark.skipif(sys.version_info < (3, 8), reason="incompatible mocking")
216+
def test_get_dataset_condition_sends_expected_request(
217+
self, mocker: MockerFixture
218+
) -> None:
219+
# Arrange
220+
mocked_get = mocker.patch("requests.get")
221+
222+
# Act
223+
self.client.metadata.get_dataset_condition(
224+
dataset="GLBX.MDP3",
225+
start_date="2018-01-01",
226+
end_date="2020-01-01",
227+
)
228+
229+
# Assert
230+
call = mocked_get.call_args.kwargs
231+
assert (
232+
call["url"]
233+
== f"https://hist.databento.com/v{db.API_VERSION}/metadata.get_dataset_condition" # noqa
234+
)
235+
assert ("dataset", "GLBX.MDP3") in call["params"]
236+
assert ("start_date", "2018-01-01") in call["params"]
237+
assert ("end_date", "2020-01-01") in call["params"]
238+
assert sorted(call["headers"].keys()) == ["accept", "user-agent"]
239+
assert call["headers"]["accept"] == "application/json"
240+
assert all(
241+
v in call["headers"]["user-agent"] for v in ("Databento/", "Python/")
242+
)
243+
assert call["timeout"] == (100, 100)
244+
assert isinstance(call["auth"], requests.auth.HTTPBasicAuth)
245+
246246
@pytest.mark.skipif(sys.version_info < (3, 8), reason="incompatible mocking")
247247
def test_get_record_count_sends_expected_request(
248248
self, mocker: MockerFixture

0 commit comments

Comments
 (0)