Skip to content

Commit 8a29ed2

Browse files
tests: refactor tests for consider new lib estructure
1 parent 7b53bc0 commit 8a29ed2

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/api_to_dataframe/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from api_to_dataframe.controller import client_builder as ClientBuilder
2-
from api_to_dataframe.common.utils import retry_strategies as RetryStrategies
1+
from api_to_dataframe.controller.client_builder import ClientBuilder
2+
from api_to_dataframe.common.utils.retry_strategies import RetryStrategies

tests/test_run.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import pytest
22
import pandas as pd
3-
import api_to_dataframe as api_to_dataframe
3+
from api_to_dataframe import ClientBuilder
44

55

66
@pytest.fixture()
77
def setup():
8-
new_client = api_to_dataframe.ClientBuilder(endpoint="https://economia.awesomeapi.com.br/last/USD-BRL")
8+
new_client = ClientBuilder(endpoint="https://economia.awesomeapi.com.br/last/USD-BRL")
99
return new_client
1010

1111

12+
@pytest.fixture()
13+
def response_setup():
14+
new_client = ClientBuilder(endpoint="https://economia.awesomeapi.com.br/last/USD-BRL")
15+
return new_client.get_api_data()
16+
17+
1218
def test_constructor_without_param():
1319
with pytest.raises(ValueError):
14-
new_client = api_to_dataframe.ClientBuilder(endpoint="")
20+
new_client = ClientBuilder(endpoint="")
1521

1622

1723
def test_constructor_with_param(setup):
@@ -22,11 +28,10 @@ def test_constructor_with_param(setup):
2228

2329
def test_response_to_json(setup):
2430
new_client = setup
25-
response = new_client._response_to_json()
31+
response = new_client.get_api_data()
2632
assert isinstance(response, dict)
2733

2834

29-
def test_to_dataframe(setup):
30-
new_client = setup
31-
df = new_client.to_dataframe()
35+
def test_to_dataframe(response_setup):
36+
df = ClientBuilder.api_to_dataframe(response_setup)
3237
assert isinstance(df, pd.DataFrame)

0 commit comments

Comments
 (0)