Skip to content

Commit a45e4ad

Browse files
committed
Started integration tests.
1 parent d853f50 commit a45e4ad

File tree

6 files changed

+109
-5
lines changed

6 files changed

+109
-5
lines changed

quickbooks/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
169169
try:
170170
result = req.json()
171171
except:
172-
raise QuickbooksException("Error reading json response", 10000)
172+
raise QuickbooksException("Error reading json response: {0}".format(req.text), 10000)
173173

174174
if req.status_code is not httplib.OK or "Fault" in result:
175175
self.handle_exceptions(result["Fault"])

quickbooks/objects/account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def __init__(self):
2727
self.SubAccount = False
2828
self.FullyQualifiedName = ""
2929
self.Active = True
30-
self.Classification = ""
31-
self.AccountType = ""
30+
self.Classification = None
31+
self.AccountType = None
3232
self.AccountSubType = ""
3333
self.Description = ""
3434
self.AcctNum = ""

quickbooks/objects/bill.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AccountBasedExpenseLineDetail(QuickbooksBaseObject):
1616

1717
def __init__(self):
1818
super(AccountBasedExpenseLineDetail, self).__init__()
19-
self.BillableStatus = ""
19+
self.BillableStatus = None
2020
self.TaxAmount = 0
2121
self.TaxInclusiveAmt = 0
2222

@@ -113,7 +113,7 @@ def __init__(self):
113113
self.DocNumber = ""
114114
self.PrivateNote = ""
115115
self.ExchangeRate = 0
116-
self.GlobalTaxCalculation = ""
116+
self.GlobalTaxCalculation = None
117117

118118
self.SalesTermRef = None
119119
self.CurrencyRef = None
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
from quickbooks.client import QuickBooks
3+
4+
5+
QuickBooks(
6+
sandbox=True,
7+
consumer_key=os.environ.get('CONSUMER_KEY'),
8+
consumer_secret=os.environ.get('CONSUMER_SECRET'),
9+
access_token=os.environ.get('ACCESS_TOKEN'),
10+
access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'),
11+
company_id=os.environ.get('COMPANY_ID')
12+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from datetime import datetime
2+
import os
3+
import unittest
4+
from quickbooks.client import QuickBooks
5+
from quickbooks.objects.account import Account
6+
7+
8+
class AccountTest(unittest.TestCase):
9+
def setUp(self):
10+
QuickBooks(
11+
sandbox=True,
12+
consumer_key=os.environ.get('CONSUMER_KEY'),
13+
consumer_secret=os.environ.get('CONSUMER_SECRET'),
14+
access_token=os.environ.get('ACCESS_TOKEN'),
15+
access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'),
16+
company_id=os.environ.get('COMPANY_ID')
17+
)
18+
19+
self.account_number = datetime.now().strftime('%d%H%M')
20+
self.name = "Test Account {0}".format(self.account_number)
21+
22+
def test_create(self):
23+
account = Account()
24+
account.AcctNum = self.account_number
25+
account.Name = self.name
26+
account.AccountSubType = "CashOnHand"
27+
account.save()
28+
29+
self.id = account.Id
30+
query_account = Account.get(account.Id)
31+
32+
self.assertEquals(account.Id, query_account.Id)
33+
self.assertEquals(query_account.Name, self.name)
34+
self.assertEquals(query_account.AcctNum, self.account_number)
35+
36+
def test_update(self):
37+
account = Account.filter(Name=self.name)[0]
38+
39+
account.Name = "Updated Name {0}".format(self.account_number)
40+
account.save()
41+
42+
self.assertEquals(account.Name, "Updated Name {0}".format(self.account_number))
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from datetime import datetime
2+
import os
3+
import unittest
4+
from quickbooks.client import QuickBooks
5+
from quickbooks.objects.bill import Bill, BillLine, AccountBasedExpenseLineDetail
6+
from quickbooks.objects.base import Ref
7+
from quickbooks.objects.vendor import Vendor
8+
9+
10+
class AccountTest(unittest.TestCase):
11+
def setUp(self):
12+
QuickBooks(
13+
sandbox=True,
14+
consumer_key=os.environ.get('CONSUMER_KEY'),
15+
consumer_secret=os.environ.get('CONSUMER_SECRET'),
16+
access_token=os.environ.get('ACCESS_TOKEN'),
17+
access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'),
18+
company_id=os.environ.get('COMPANY_ID')
19+
)
20+
21+
self.account_number = datetime.now().strftime('%d%H%M')
22+
self.name = "Test Account {0}".format(self.account_number)
23+
24+
def test_create(self):
25+
bill = Bill()
26+
27+
line = BillLine()
28+
line.Amount = 200
29+
line.DetailType = "AccountBasedExpenseLineDetail"
30+
31+
account_ref = Ref()
32+
account_ref.type = "Account"
33+
account_ref.value = 1
34+
line.AccountBasedExpenseLineDetail = AccountBasedExpenseLineDetail()
35+
line.AccountBasedExpenseLineDetail.AccountRef = account_ref
36+
bill.Line.append(line)
37+
38+
vendor = Vendor.all(max_results=1)[0]
39+
bill.VendorRef = vendor.to_ref()
40+
41+
bill.save()
42+
43+
query_bill = Bill.get(bill.Id)
44+
45+
self.assertEquals(query_bill.Id, bill.Id)
46+
self.assertEquals(len(query_bill.Line), 1)
47+
self.assertEquals(query_bill.Line[0].Amount, 200.0)
48+
49+
def test_update(self):
50+
pass

0 commit comments

Comments
 (0)