diff --git a/setup.cfg b/setup.cfg index 137d138..6601edd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = quickbase-json-api-client -version = 0.0.10 +version = 0.1.0 author = Robert Carroll author_email = rob@shenandoah.capital description = Python wrapper for quickbase JSON API. diff --git a/src/quickbase_json/__init__.py b/src/quickbase_json/__init__.py index e69de29..588a403 100644 --- a/src/quickbase_json/__init__.py +++ b/src/quickbase_json/__init__.py @@ -0,0 +1,3 @@ +from quickbase_json.client import QuickbaseJSONClient + +QBClient = QuickbaseJSONClient diff --git a/src/quickbase_json/qb_response.py b/src/quickbase_json/qb_response.py index ce0eaad..cd10da9 100644 --- a/src/quickbase_json/qb_response.py +++ b/src/quickbase_json/qb_response.py @@ -24,16 +24,17 @@ def wrapper(self, *args, **kwargs): class QBResponse(dict): - def __init__(self, requests_response): + def __init__(self, requests_response=None, **kwargs): super().__init__() - self.ok = requests_response.ok - self.status_code = requests_response.status_code - self.text = requests_response.text + if requests_response: + self.ok = requests_response.ok + self.status_code = requests_response.status_code + self.text = requests_response.text class QBQueryResponse(QBResponse): - def __init__(self, res, **kwargs): + def __init__(self, res=None, **kwargs): self.response_type = 'records' self.operations = [] # potential to load sample data for testing diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 8d69c4e..4710d40 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,7 +1,11 @@ +import sys + import pytest # test where -from src.quickbase_json.helpers import Where, IncorrectParameters +import os +import os +from quickbase_json.helpers import Where, IncorrectParameters @pytest.mark.parametrize('fid, operator, value, expected', [ diff --git a/tests/test_response.py b/tests/test_response.py index ede1c70..4eb4116 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -1,10 +1,11 @@ import datetime +import sys import pytest # test where -from src.quickbase_json.qb_response import QBResponse -from src.quickbase_json.helpers import Where, IncorrectParameters +import os +from src.quickbase_json.qb_response import QBQueryResponse from tests import sample_data from copy import deepcopy @@ -14,18 +15,18 @@ (sample_data.record_data, sample_data.record_data_load) ]) def test_load(data, expected): - assert QBResponse('records', sample_data=data) == expected + assert QBQueryResponse(sample_data=data) == expected # test getting info, basic tests, does not test formatting def test_get_info(): - assert "{'6': {'value': 'Andre Harris'}, '7': {'value': 10.0}, '8': {'value': '2019-12-18T08:00:00.000Z'}}" in QBResponse( - 'records', sample_data=sample_data.record_data.copy()).info(prt=False) + assert "{'6': {'value': 'Andre Harris'}, '7': {'value': 10.0}, '8': {'value': '2019-12-18T08:00:00.000Z'}}" in QBQueryResponse( + sample_data=sample_data.record_data.copy()).info(prt=False) # test getting info, basic tests, does not test formatting def test_denest(): - res = QBResponse('records', sample_data=deepcopy(sample_data.record_data)) + res = QBQueryResponse(sample_data=deepcopy(sample_data.record_data)) res.denest() assert res.data() == [{'8': '2019-12-18T08:00:00.000Z', '6': 'Andre Harris', '7': 10}] @@ -33,12 +34,12 @@ def test_denest(): # test datetime convert def test_convert_datetime(): # test datetime convert w/o denest - res = QBResponse('records', sample_data=deepcopy(sample_data.record_data)) + res = QBQueryResponse(sample_data=deepcopy(sample_data.record_data)) res.convert_type('datetime') dt_test = res.data()[0].get('8').get('value') # test datetime convert w/ denest - res2 = QBResponse('records', sample_data=deepcopy(sample_data.record_data)) + res2 = QBQueryResponse('records', sample_data=deepcopy(sample_data.record_data)) res2.denest() res2.convert_type('datetime') dt_test2 = res2.data()[0].get('8') @@ -51,7 +52,7 @@ def test_convert_datetime(): # test currency convert def test_convert_currency(): # test datetime convert w/o denest - res = QBResponse('records', sample_data=deepcopy(sample_data.record_data_currency)) + res = QBQueryResponse('records', sample_data=deepcopy(sample_data.record_data_currency)) res.convert_type('numeric currency', fmt='$') res.denest() @@ -63,7 +64,7 @@ def test_convert_currency(): # test datetime convert def test_round_ints(): # test converting ints with floating point - res = QBResponse('records', sample_data=deepcopy(sample_data.record_data)) + res = QBQueryResponse('records', sample_data=deepcopy(sample_data.record_data)) # assert float, then int assert type(res.data()[0].get('7').get('value')) == float @@ -72,7 +73,7 @@ def test_round_ints(): def test_operations(): - res = QBResponse('records', sample_data=sample_data.record_data) + res = QBQueryResponse('records', sample_data=sample_data.record_data) assert res.operations == [] res.denest() assert res.operations == ['denest']