Skip to content

Commit f322e1d

Browse files
authored
remove dotenv and upgrade other deps (#173)
* remove dotenv and upgrade other deps * fmt * read api key from env in e2e tests * fmt * remove unused os import
1 parent 27f7b6c commit f322e1d

File tree

5 files changed

+140
-172
lines changed

5 files changed

+140
-172
lines changed

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ classifiers = [
2020
"Operating System :: OS Independent",
2121
]
2222
dependencies = [
23-
"aiohttp~=3.10.0",
23+
"aiohttp~=3.12.15",
2424
"dataclasses-json~=0.6.4",
25-
"python-dateutil~=2.8.2",
26-
"requests~=2.31.0",
25+
"python-dateutil~=2.9.0",
26+
"requests~=2.32.5",
2727
"ndjson~=0.3.1",
28-
"Deprecated~=1.2.14",
28+
"Deprecated~=1.2.18",
2929
]
3030
dynamic = ["version"]
3131

@@ -48,7 +48,6 @@ dev = [
4848
# Optional features
4949
"pandas>=1.0.0",
5050
"pandas-stubs>=1.0.0",
51-
"python-dotenv>=1.0.0",
5251
"aiounittest>=1.4.2",
5352
"colorlover>=0.3.0",
5453
"plotly>=5.9.0",

tests/e2e/test_async_client.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import os
21
import unittest
32

43
import aiounittest
5-
import dotenv
64
import pandas as pd
75

86
from dune_client.client_async import AsyncDuneClient
@@ -16,31 +14,29 @@ def setUp(self) -> None:
1614
name="Query that returns multiple rows",
1715
query_id=3435763,
1816
)
19-
dotenv.load_dotenv()
20-
self.valid_api_key = os.environ["DUNE_API_KEY"]
2117

2218
async def test_disconnect(self):
23-
dune = AsyncDuneClient(self.valid_api_key)
19+
dune = AsyncDuneClient()
2420
await dune.connect()
2521
results = (await dune.refresh(self.query)).get_rows()
2622
assert len(results) > 0
2723
await dune.disconnect()
2824
assert dune._session.closed
2925

3026
async def test_refresh_context_manager_singleton(self):
31-
dune = AsyncDuneClient(self.valid_api_key)
27+
dune = AsyncDuneClient()
3228
async with dune as cl:
3329
results = (await cl.refresh(self.query)).get_rows()
3430
assert len(results) > 0
3531

3632
async def test_refresh_context_manager(self):
37-
async with AsyncDuneClient(self.valid_api_key) as cl:
33+
async with AsyncDuneClient() as cl:
3834
results = (await cl.refresh(self.query)).get_rows()
3935
assert len(results) > 0
4036

4137
async def test_refresh_with_pagination(self):
4238
# Arrange
43-
async with AsyncDuneClient(self.valid_api_key) as cl:
39+
async with AsyncDuneClient() as cl:
4440
# Act
4541
results = (await cl.refresh(self.multi_rows_query, batch_size=1)).get_rows()
4642

@@ -55,7 +51,7 @@ async def test_refresh_with_pagination(self):
5551

5652
async def test_refresh_with_filters(self):
5753
# Arrange
58-
async with AsyncDuneClient(self.valid_api_key) as cl:
54+
async with AsyncDuneClient() as cl:
5955
# Act
6056
results = (await cl.refresh(self.multi_rows_query, filters="number < 3")).get_rows()
6157

@@ -64,7 +60,7 @@ async def test_refresh_with_filters(self):
6460

6561
async def test_refresh_csv_with_pagination(self):
6662
# Arrange
67-
async with AsyncDuneClient(self.valid_api_key) as cl:
63+
async with AsyncDuneClient() as cl:
6864
# Act
6965
result_csv = await cl.refresh_csv(self.multi_rows_query, batch_size=1)
7066

@@ -79,7 +75,7 @@ async def test_refresh_csv_with_pagination(self):
7975

8076
async def test_refresh_csv_with_filters(self):
8177
# Arrange
82-
async with AsyncDuneClient(self.valid_api_key) as cl:
78+
async with AsyncDuneClient() as cl:
8379
# Act
8480
result_csv = await cl.refresh_csv(self.multi_rows_query, filters="number < 3")
8581

@@ -91,17 +87,17 @@ async def test_refresh_csv_with_filters(self):
9187

9288
@unittest.skip("Large performance tier doesn't currently work.")
9389
async def test_refresh_context_manager_performance_large(self):
94-
async with AsyncDuneClient(self.valid_api_key) as cl:
90+
async with AsyncDuneClient() as cl:
9591
results = (await cl.refresh(self.query, performance="large")).get_rows()
9692
assert len(results) > 0
9793

9894
async def test_get_latest_result_with_query_object(self):
99-
async with AsyncDuneClient(self.valid_api_key) as cl:
95+
async with AsyncDuneClient() as cl:
10096
results = (await cl.get_latest_result(self.query)).get_rows()
10197
assert len(results) > 0
10298

10399
async def test_get_latest_result_with_query_id(self):
104-
async with AsyncDuneClient(self.valid_api_key) as cl:
100+
async with AsyncDuneClient() as cl:
105101
results = (await cl.get_latest_result(self.query.query_id)).get_rows()
106102
assert len(results) > 0
107103

tests/e2e/test_client.py

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import copy
2-
import os
32
import time
43
import unittest
54
import warnings
65
from pathlib import Path
76

8-
import dotenv
97
import pandas as pd
108
import pytest
119

@@ -23,8 +21,6 @@
2321
from dune_client.query import QueryBase
2422
from dune_client.types import QueryParameter
2523

26-
dotenv.load_dotenv()
27-
2824

2925
class TestDuneClient(unittest.TestCase):
3026
def setUp(self) -> None:
@@ -43,7 +39,6 @@ def setUp(self) -> None:
4339
name="Query that returns multiple rows",
4440
query_id=3435763,
4541
)
46-
self.valid_api_key = os.environ["DUNE_API_KEY"]
4742

4843
def copy_query_and_change_parameters(self) -> QueryBase:
4944
new_query = copy.copy(self.query)
@@ -79,19 +74,19 @@ def test_default_constructor_reads_env(self):
7974

8075
def test_get_execution_status(self):
8176
query = QueryBase(name="No Name", query_id=1276442, params=[])
82-
dune = DuneClient(self.valid_api_key)
77+
dune = DuneClient()
8378
job_id = dune.execute_query(query).execution_id
8479
status = dune.get_execution_status(job_id)
8580
assert status.state in [ExecutionState.EXECUTING, ExecutionState.PENDING]
8681

8782
def test_run_query(self):
88-
dune = DuneClient(self.valid_api_key)
83+
dune = DuneClient()
8984
results = dune.run_query(self.query).get_rows()
9085
assert len(results) > 0
9186

9287
def test_run_query_paginated(self):
9388
# Arrange
94-
dune = DuneClient(self.valid_api_key)
89+
dune = DuneClient()
9590

9691
# Act
9792
results = dune.run_query(self.multi_rows_query, batch_size=1).get_rows()
@@ -107,7 +102,7 @@ def test_run_query_paginated(self):
107102

108103
def test_run_query_with_filters(self):
109104
# Arrange
110-
dune = DuneClient(self.valid_api_key)
105+
dune = DuneClient()
111106

112107
# Act
113108
results = dune.run_query(self.multi_rows_query, filters="number < 3").get_rows()
@@ -116,18 +111,18 @@ def test_run_query_with_filters(self):
116111
assert results == [{"number": 1}, {"number": 2}]
117112

118113
def test_run_query_performance_large(self):
119-
dune = DuneClient(self.valid_api_key)
114+
dune = DuneClient()
120115
results = dune.run_query(self.query, performance="large").get_rows()
121116
assert len(results) > 0
122117

123118
def test_run_query_dataframe(self):
124-
dune = DuneClient(self.valid_api_key)
119+
dune = DuneClient()
125120
pd = dune.run_query_dataframe(self.query)
126121
assert len(pd) > 0
127122

128123
def test_parameters_recognized(self):
129124
new_query = self.copy_query_and_change_parameters()
130-
dune = DuneClient(self.valid_api_key)
125+
dune = DuneClient()
131126
results = dune.run_query(new_query)
132127
assert results.get_rows() == [
133128
{
@@ -139,7 +134,7 @@ def test_parameters_recognized(self):
139134
]
140135

141136
def test_endpoints(self):
142-
dune = DuneClient(self.valid_api_key)
137+
dune = DuneClient()
143138
execution_response = dune.execute_query(self.query)
144139
assert isinstance(execution_response, ExecutionResponse)
145140
job_id = execution_response.execution_id
@@ -151,7 +146,7 @@ def test_endpoints(self):
151146
assert len(results) > 0
152147

153148
def test_cancel_execution(self):
154-
dune = DuneClient(self.valid_api_key)
149+
dune = DuneClient()
155150
query = QueryBase(
156151
name="Long Running Query",
157152
query_id=1229120,
@@ -181,7 +176,7 @@ def test_invalid_api_key_error(self):
181176
assert str(err.value) == "Can't build ResultsResponse from {'error': 'invalid API Key'}"
182177

183178
def test_query_not_found_error(self):
184-
dune = DuneClient(self.valid_api_key)
179+
dune = DuneClient()
185180
query = copy.copy(self.query)
186181
query.query_id = 99999999 # Invalid Query Id.
187182

@@ -190,7 +185,7 @@ def test_query_not_found_error(self):
190185
assert str(err.value) == "Can't build ExecutionResponse from {'error': 'Query not found'}"
191186

192187
def test_internal_error(self):
193-
dune = DuneClient(self.valid_api_key)
188+
dune = DuneClient()
194189
query = copy.copy(self.query)
195190
# This query ID is too large!
196191
query.query_id = 9999999999999
@@ -203,7 +198,7 @@ def test_internal_error(self):
203198
)
204199

205200
def test_invalid_job_id_error(self):
206-
dune = DuneClient(self.valid_api_key)
201+
dune = DuneClient()
207202
with pytest.raises(DuneError) as err:
208203
dune.get_execution_status("Wonky Job ID")
209204
assert (
@@ -212,18 +207,18 @@ def test_invalid_job_id_error(self):
212207
)
213208

214209
def test_get_latest_result_with_query_object(self):
215-
dune = DuneClient(self.valid_api_key)
210+
dune = DuneClient()
216211
results = dune.get_latest_result(self.query).get_rows()
217212
assert len(results) > 0
218213

219214
def test_get_latest_result_with_query_id(self):
220-
dune = DuneClient(self.valid_api_key)
215+
dune = DuneClient()
221216
results = dune.get_latest_result(self.query.query_id).get_rows()
222217
assert len(results) > 0
223218

224219
@unittest.skip("Requires custom namespace and table_name input.")
225220
def test_upload_csv_success(self):
226-
client = DuneClient(self.valid_api_key)
221+
client = DuneClient()
227222
assert client.upload_csv(
228223
table_name="e2e-test",
229224
description="best data",
@@ -234,7 +229,7 @@ def test_upload_csv_success(self):
234229
def test_create_table_success(self):
235230
# Make sure the table doesn't already exist.
236231
# You will need to change the namespace to your own.
237-
client = DuneClient(self.valid_api_key)
232+
client = DuneClient()
238233

239234
namespace = "bh2smith"
240235
table_name = "dataset_e2e_test"
@@ -275,7 +270,7 @@ def test_create_table_error(self):
275270
def test_insert_table_csv_success(self):
276271
# Make sure the table already exists and csv matches table schema.
277272
# You will need to change the namespace to your own.
278-
client = DuneClient(self.valid_api_key)
273+
client = DuneClient()
279274
namespace = "bh2smith"
280275
table_name = "dataset_e2e_test"
281276
client.create_table(
@@ -293,7 +288,7 @@ def test_insert_table_csv_success(self):
293288

294289
@unittest.skip("Requires custom namespace and table_name input.")
295290
def test_clear_data(self):
296-
client = DuneClient(self.valid_api_key)
291+
client = DuneClient()
297292
namespace = "bh2smith"
298293
table_name = "dataset_e2e_test"
299294
assert client.clear_data(namespace, table_name) == ClearTableResult(
@@ -304,7 +299,7 @@ def test_clear_data(self):
304299
def test_insert_table_json_success(self):
305300
# Make sure the table already exists and json matches table schema.
306301
# You will need to change the namespace to your own.
307-
client = DuneClient(self.valid_api_key)
302+
client = DuneClient()
308303
with Path("./tests/fixtures/sample_table_insert.json").open("rb") as data:
309304
assert client.insert_table(
310305
namespace="test",
@@ -317,7 +312,7 @@ def test_insert_table_json_success(self):
317312
def test_delete_table_success(self):
318313
# Make sure the table doesn't already exist.
319314
# You will need to change the namespace to your own.
320-
client = DuneClient(self.valid_api_key)
315+
client = DuneClient()
321316

322317
namespace = "test"
323318
table_name = "dataset_e2e_test"
@@ -330,7 +325,7 @@ def test_delete_table_success(self):
330325

331326
def test_download_csv_with_pagination(self):
332327
# Arrange
333-
client = DuneClient(self.valid_api_key)
328+
client = DuneClient()
334329
client.run_query(self.multi_rows_query)
335330

336331
# Act
@@ -347,7 +342,7 @@ def test_download_csv_with_pagination(self):
347342

348343
def test_download_csv_with_filters(self):
349344
# Arrange
350-
client = DuneClient(self.valid_api_key)
345+
client = DuneClient()
351346
client.run_query(self.multi_rows_query)
352347

353348
# Act
@@ -363,7 +358,7 @@ def test_download_csv_with_filters(self):
363358
]
364359

365360
def test_download_csv_success_by_id(self):
366-
client = DuneClient(self.valid_api_key)
361+
client = DuneClient()
367362
new_query = self.copy_query_and_change_parameters()
368363
# Run query with new parameters
369364
client.run_query(new_query)
@@ -380,7 +375,7 @@ def test_download_csv_success_by_id(self):
380375
]
381376

382377
def test_download_csv_success_with_params(self):
383-
client = DuneClient(self.valid_api_key)
378+
client = DuneClient()
384379
# Download CSV with query and given parameters.
385380
result_csv = client.download_csv(self.query)
386381
# Expect the result to be relative to values of given parameters.
@@ -402,8 +397,7 @@ def test_download_csv_success_with_params(self):
402397
@unittest.skip("This is an enterprise only endpoint that can no longer be tested.")
403398
class TestCRUDOps(unittest.TestCase):
404399
def setUp(self) -> None:
405-
self.valid_api_key = os.environ["DUNE_API_KEY"]
406-
self.client = DuneClient(self.valid_api_key, client_version="alpha/v1")
400+
self.client = DuneClient(client_version="alpha/v1")
407401
self.existing_query_id = 2713571
408402

409403
@unittest.skip("Works fine, but creates too many queries")

tests/e2e/test_custom_endpoints.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
import os
21
import unittest
32
import warnings
43

5-
import dotenv
6-
74
from dune_client.client import DuneClient
85

9-
dotenv.load_dotenv()
10-
116

127
@unittest.skip("endpoint no longer exists - {'error': 'Custom endpoint not found'}")
138
class TestCustomEndpoints(unittest.TestCase):
14-
def setUp(self) -> None:
15-
self.valid_api_key = os.environ["DUNE_API_KEY"]
16-
179
def test_getting_custom_endpoint_results(self):
18-
dune = DuneClient(self.valid_api_key)
10+
dune = DuneClient()
1911
with warnings.catch_warnings(record=True) as w:
2012
warnings.simplefilter("always")
2113
results = dune.get_custom_endpoint_result("dune", "new-test")

0 commit comments

Comments
 (0)