File tree Expand file tree Collapse file tree 5 files changed +42
-12
lines changed Expand file tree Collapse file tree 5 files changed +42
-12
lines changed Original file line number Diff line number Diff line change 11[tool .poetry ]
22name = " api-to-dataframe"
3- version = " 0.0.11 "
3+ version = " 0.1.0 "
44description = " A package to convert API responses to pandas dataframe"
55authors = [" IvanildoBarauna <ivanildo.jnr@outlook.com>" ]
66readme = " README.md"
77license = " MIT"
88packages = [{ include = " api_to_dataframe" , from = " src" }]
99classifiers =[
10- " Development Status :: 1 - Planning " ,
10+ " Development Status :: 2 - Pre-Alpha " ,
1111 " Intended Audience :: Developers" ,
1212 " License :: OSI Approved :: MIT License" ,
1313 " Programming Language :: Python :: 3" ,
Original file line number Diff line number Diff line change 1- from . import run as ApiToDataframe
1+ from src . api_to_dataframe . main import ClientBuilder
Original file line number Diff line number Diff line change 1+ import requests
2+ import pandas as pd
3+
4+
5+ class ClientBuilder :
6+ def __init__ (self , endpoint : str ):
7+ if endpoint == "" :
8+ raise ValueError ("::: endpoint param is mandatory :::" )
9+ else :
10+ self .endpoint = endpoint
11+
12+ def _response_to_json (self ):
13+ response = requests .get (self .url )
14+
15+ if response .ok :
16+ return response .json ()
17+ else :
18+ raise ConnectionError (response .status_code )
19+
20+ def to_dataframe (self ):
21+ df = pd .DataFrame ([self ._response_to_json ()])
22+ return df
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import pytest
2- from src .api_to_dataframe import run
2+ import src .api_to_dataframe as apitodf
33
4- def test_main ():
5- assert True
4+
5+ def test_constructor_without_param ():
6+ with pytest .raises (ValueError ):
7+ new_client = apitodf .ClientBuilder (endpoint = "" )
8+
9+
10+ @pytest .fixture ()
11+ def test_constructor_with_param ():
12+ expected_result = "param1"
13+ new_client = apitodf .ClientBuilder (endpoint = expected_result )
14+ assert new_client .endpoint == expected_result
15+ return new_client
16+
17+
18+ def test_response_to_json_with_valid_endpoint (test_constructor_with_param ):
19+ pass
You can’t perform that action at this time.
0 commit comments