forked from routablehq/python-quickbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cdc.py
More file actions
90 lines (83 loc) · 2.19 KB
/
test_cdc.py
File metadata and controls
90 lines (83 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import unittest
try:
from mock import patch
except ImportError:
from unittest.mock import patch
from quickbooks.cdc import change_data_capture
from quickbooks.objects import Invoice, Customer
from quickbooks import QuickBooks
from datetime import datetime
class ChangeDataCaptureTest(unittest.TestCase):
def setUp(self):
self.qb_client = QuickBooks(
sandbox=True,
consumer_key="update_consumer_key",
consumer_secret="update_consumer_secret",
access_token="update_access_token",
access_token_secret="update_access_token_secret",
company_id="update_company_id",
callback_url="update_callback_url"
)
self.cdc_json_response = {
"CDCResponse": [
{
"QueryResponse": [
{
"Customer": [
{
"Id": 1,
"DisplayName": "TestCustomer",
"Job": False,
"Balance": 0
}
],
"startPosition": 1,
"maxResults": 1
},
{
"Invoice": [
{
"DocNumber": "12344",
"TxnDate": "2017-01-01",
"Line": [
{
"Id": 1
},
{
"Id": 2
}
]
},
{
"DocNumber": "12345",
"TxnDate": "2017-01-01",
"Line": [
{
"Id": 1
},
{
"Id": 2
}
]
},
],
"startPosition": 1,
"maxResults": 2
}
]
}
],
"time": "2016-01-01T00:00:00"
}
@patch('quickbooks.client.QuickBooks.make_request')
def test_change_data_capture(self, make_request):
make_request.return_value = self.cdc_json_response.copy()
cdc_response = change_data_capture([Invoice, Customer], "2017-01-01T00:00:00")
self.assertEquals(1, len(cdc_response.Customer))
self.assertEquals(2, len(cdc_response.Invoice))
@patch('quickbooks.client.QuickBooks.make_request')
def test_change_data_capture_with_timestamp(self, make_request):
make_request.return_value = self.cdc_json_response.copy()
cdc_response_with_datetime = change_data_capture([Invoice, Customer], datetime(2017, 1, 1, 0, 0, 0))
self.assertEquals(1, len(cdc_response_with_datetime.Customer))
self.assertEquals(2, len(cdc_response_with_datetime.Invoice))