Skip to content

Commit

Permalink
tests: refactor tests for consider new lib estructure
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanildoBarauna committed Jun 13, 2024
1 parent 7b53bc0 commit 8a29ed2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/api_to_dataframe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from api_to_dataframe.controller import client_builder as ClientBuilder
from api_to_dataframe.common.utils import retry_strategies as RetryStrategies
from api_to_dataframe.controller.client_builder import ClientBuilder
from api_to_dataframe.common.utils.retry_strategies import RetryStrategies
19 changes: 12 additions & 7 deletions tests/test_run.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import pytest
import pandas as pd
import api_to_dataframe as api_to_dataframe
from api_to_dataframe import ClientBuilder


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


@pytest.fixture()
def response_setup():
new_client = ClientBuilder(endpoint="https://economia.awesomeapi.com.br/last/USD-BRL")
return new_client.get_api_data()


def test_constructor_without_param():
with pytest.raises(ValueError):
new_client = api_to_dataframe.ClientBuilder(endpoint="")
new_client = ClientBuilder(endpoint="")


def test_constructor_with_param(setup):
Expand All @@ -22,11 +28,10 @@ def test_constructor_with_param(setup):

def test_response_to_json(setup):
new_client = setup
response = new_client._response_to_json()
response = new_client.get_api_data()
assert isinstance(response, dict)


def test_to_dataframe(setup):
new_client = setup
df = new_client.to_dataframe()
def test_to_dataframe(response_setup):
df = ClientBuilder.api_to_dataframe(response_setup)
assert isinstance(df, pd.DataFrame)

0 comments on commit 8a29ed2

Please sign in to comment.