Skip to content

Commit b3aafa1

Browse files
committed
Added tests and unicodes for Invoice and Item.
1 parent bb62847 commit b3aafa1

File tree

4 files changed

+62
-9
lines changed

4 files changed

+62
-9
lines changed

quickbooks/objects/invoice.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def __init__(self):
1313
self.DiscountPercent = 0
1414
self.DiscountAccountRef = None
1515

16+
def __unicode__(self):
17+
return self.DiscountPercent
18+
1619

1720
class SalesItemLineDetail(QuickbooksBaseObject):
1821
class_dict = {
@@ -25,6 +28,9 @@ def __init__(self):
2528
self.UnitPrice = 0
2629
self.Qty = 0
2730

31+
def __unicode__(self):
32+
return self.UnitPrice
33+
2834

2935
class InvoiceDetail(QuickbooksBaseObject):
3036
class_dict = {
@@ -39,6 +45,8 @@ def __init__(self):
3945
self.Amount = ""
4046
self.DetailType = ""
4147

48+
def __unicode__(self):
49+
return "[{0}] {1} {2}".format(self.LineNum, self.Description, self.Amount)
4250

4351
class Invoice(QuickbooksManagedObject):
4452
"""
@@ -91,3 +99,6 @@ def __init__(self):
9199
self.CustomerMemo = None
92100

93101
self.CustomField = []
102+
103+
def __unicode__(self):
104+
return self.TotalAmt

tests/unit/objects/test_estimate.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55

66
class EstimateTests(unittest.TestCase):
7-
def setUp(self):
8-
pass
9-
107
def test_unicode(self):
118
estimate = Estimate()
129
estimate.TotalAmt = 10
@@ -15,9 +12,6 @@ def test_unicode(self):
1512

1613

1714
class EstimatelineTests(unittest.TestCase):
18-
def setUp(self):
19-
pass
20-
2115
def test_unicode(self):
2216
estimateline = EstimateLine()
2317
estimateline.Amount = 100
@@ -26,9 +20,6 @@ def test_unicode(self):
2620

2721

2822
class SalesItemLineDetailTests(unittest.TestCase):
29-
def setUp(self):
30-
pass
31-
3223
def test_unicode(self):
3324
sales_detail = SalesItemLineDetail()
3425
sales_detail.UnitPrice = 10

tests/unit/objects/test_invoice.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import unittest
2+
3+
from quickbooks.objects.invoice import Invoice, InvoiceDetail, SalesItemLineDetail, DiscountLineDetail
4+
5+
6+
class InvoiceTests(unittest.TestCase):
7+
def test_unicode(self):
8+
invoice = Invoice()
9+
invoice.TotalAmt = 10
10+
11+
self.assertEquals(invoice.__unicode__(), 10)
12+
13+
14+
class InvoiceDetailTests(unittest.TestCase):
15+
def test_unicode(self):
16+
detail = InvoiceDetail()
17+
detail.LineNum = 1
18+
detail.Description = "Product Description"
19+
detail.Amount = 100
20+
21+
self.assertEquals(detail.__unicode__(), "[1] Product Description 100")
22+
23+
24+
class SalesItemLineDetailTests(unittest.TestCase):
25+
def test_unicode(self):
26+
detail = SalesItemLineDetail()
27+
detail.UnitPrice = 100
28+
29+
self.assertEquals(detail.__unicode__(), 100)
30+
31+
32+
class DiscountLineDetailTests(unittest.TestCase):
33+
def test_unicode(self):
34+
detail = DiscountLineDetail()
35+
detail.DiscountPercent = 5
36+
37+
self.assertEquals(detail.__unicode__(), 5)

tests/unit/objects/test_item.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
3+
from quickbooks.objects.item import Item
4+
5+
6+
class ItemTests(unittest.TestCase):
7+
def setUp(self):
8+
pass
9+
10+
def test_unicode(self):
11+
item = Item()
12+
item.Name = "test"
13+
14+
self.assertEquals(item.__unicode__(), "test")

0 commit comments

Comments
 (0)