Skip to content

Commit 1403f19

Browse files
committed
restructuring imports
1 parent 0e19bc6 commit 1403f19

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = quickbase-json-api-client
3-
version = 0.0.10
3+
version = 0.1.0
44
author = Robert Carroll
55
author_email = rob@shenandoah.capital
66
description = Python wrapper for quickbase JSON API.

src/quickbase_json/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from quickbase_json.client import QuickbaseJSONClient
2+
3+
QBClient = QuickbaseJSONClient

src/quickbase_json/qb_response.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ def wrapper(self, *args, **kwargs):
2424

2525

2626
class QBResponse(dict):
27-
def __init__(self, requests_response):
27+
def __init__(self, requests_response=None, **kwargs):
2828
super().__init__()
29-
self.ok = requests_response.ok
30-
self.status_code = requests_response.status_code
31-
self.text = requests_response.text
29+
if requests_response:
30+
self.ok = requests_response.ok
31+
self.status_code = requests_response.status_code
32+
self.text = requests_response.text
3233

3334

3435
class QBQueryResponse(QBResponse):
3536

36-
def __init__(self, res, **kwargs):
37+
def __init__(self, res=None, **kwargs):
3738
self.response_type = 'records'
3839
self.operations = []
3940
# potential to load sample data for testing

tests/__init__.py

Whitespace-only changes.

tests/test_helpers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import sys
2+
13
import pytest
24

35
# test where
4-
from src.quickbase_json.helpers import Where, IncorrectParameters
6+
import os
7+
import os
8+
from quickbase_json.helpers import Where, IncorrectParameters
59

610

711
@pytest.mark.parametrize('fid, operator, value, expected', [

tests/test_response.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import datetime
2+
import sys
23

34
import pytest
45

56
# test where
6-
from src.quickbase_json.qb_response import QBResponse
7-
from src.quickbase_json.helpers import Where, IncorrectParameters
7+
import os
8+
from src.quickbase_json.qb_response import QBQueryResponse
89
from tests import sample_data
910
from copy import deepcopy
1011

@@ -14,31 +15,31 @@
1415
(sample_data.record_data, sample_data.record_data_load)
1516
])
1617
def test_load(data, expected):
17-
assert QBResponse('records', sample_data=data) == expected
18+
assert QBQueryResponse(sample_data=data) == expected
1819

1920

2021
# test getting info, basic tests, does not test formatting
2122
def test_get_info():
22-
assert "{'6': {'value': 'Andre Harris'}, '7': {'value': 10.0}, '8': {'value': '2019-12-18T08:00:00.000Z'}}" in QBResponse(
23-
'records', sample_data=sample_data.record_data.copy()).info(prt=False)
23+
assert "{'6': {'value': 'Andre Harris'}, '7': {'value': 10.0}, '8': {'value': '2019-12-18T08:00:00.000Z'}}" in QBQueryResponse(
24+
sample_data=sample_data.record_data.copy()).info(prt=False)
2425

2526

2627
# test getting info, basic tests, does not test formatting
2728
def test_denest():
28-
res = QBResponse('records', sample_data=deepcopy(sample_data.record_data))
29+
res = QBQueryResponse(sample_data=deepcopy(sample_data.record_data))
2930
res.denest()
3031
assert res.data() == [{'8': '2019-12-18T08:00:00.000Z', '6': 'Andre Harris', '7': 10}]
3132

3233

3334
# test datetime convert
3435
def test_convert_datetime():
3536
# test datetime convert w/o denest
36-
res = QBResponse('records', sample_data=deepcopy(sample_data.record_data))
37+
res = QBQueryResponse(sample_data=deepcopy(sample_data.record_data))
3738
res.convert_type('datetime')
3839
dt_test = res.data()[0].get('8').get('value')
3940

4041
# test datetime convert w/ denest
41-
res2 = QBResponse('records', sample_data=deepcopy(sample_data.record_data))
42+
res2 = QBQueryResponse('records', sample_data=deepcopy(sample_data.record_data))
4243
res2.denest()
4344
res2.convert_type('datetime')
4445
dt_test2 = res2.data()[0].get('8')
@@ -51,7 +52,7 @@ def test_convert_datetime():
5152
# test currency convert
5253
def test_convert_currency():
5354
# test datetime convert w/o denest
54-
res = QBResponse('records', sample_data=deepcopy(sample_data.record_data_currency))
55+
res = QBQueryResponse('records', sample_data=deepcopy(sample_data.record_data_currency))
5556
res.convert_type('numeric currency', fmt='$')
5657
res.denest()
5758

@@ -63,7 +64,7 @@ def test_convert_currency():
6364
# test datetime convert
6465
def test_round_ints():
6566
# test converting ints with floating point
66-
res = QBResponse('records', sample_data=deepcopy(sample_data.record_data))
67+
res = QBQueryResponse('records', sample_data=deepcopy(sample_data.record_data))
6768

6869
# assert float, then int
6970
assert type(res.data()[0].get('7').get('value')) == float
@@ -72,7 +73,7 @@ def test_round_ints():
7273

7374

7475
def test_operations():
75-
res = QBResponse('records', sample_data=sample_data.record_data)
76+
res = QBQueryResponse('records', sample_data=sample_data.record_data)
7677
assert res.operations == []
7778
res.denest()
7879
assert res.operations == ['denest']

0 commit comments

Comments
 (0)