コード例 #1
0
    def test_reconnect_account(self, make_req):
        qb_client = client.QuickBooks()
        qb_client.company_id = "1234"

        qb_client.reconnect_account()
        url = "https://appcenter.intuit.com/api/v1/connection/reconnect"
        make_req.assert_called_with("GET", url)
コード例 #2
0
    def test_get_report(self, make_req):
        qb_client = client.QuickBooks()
        qb_client.company_id = "1234"

        qb_client.get_report("profitandloss", {1: 2})
        url = "https://sandbox-quickbooks.api.intuit.com/v3/company/1234/reports/profitandloss"
        make_req.assert_called_with("GET", url, params={1: 2})
コード例 #3
0
    def test_get_current_user(self, get):
        qb_client = client.QuickBooks()
        qb_client.company_id = "1234"

        qb_client.get_current_user()
        url = "https://appcenter.intuit.com/api/v1/user/current"
        get.assert_called_with(url)
コード例 #4
0
    def test_disconnect_account(self, get):
        qb_client = client.QuickBooks()
        qb_client.company_id = "1234"

        qb_client.disconnect_account()
        url = "https://appcenter.intuit.com/api/v1/connection/disconnect"
        get.assert_called_with(url)
コード例 #5
0
    def test_client_updated(self):
        self.qb_client = client.QuickBooks(
            sandbox=False,
            company_id="company_id",
        )

        self.qb_client2 = client.QuickBooks(
            sandbox=True,
            company_id="update_company_id",
        )

        self.assertEquals(self.qb_client.sandbox, True)
        self.assertEquals(self.qb_client.company_id, "update_company_id")

        self.assertEquals(self.qb_client2.sandbox, True)
        self.assertEquals(self.qb_client2.company_id, "update_company_id")
コード例 #6
0
    def test_disable_global(self):
        client.QuickBooks.disable_global()
        self.qb_client = client.QuickBooks()

        self.assertFalse(self.qb_client.sandbox)
        self.assertFalse(self.qb_client.company_id)
        self.assertFalse(self.qb_client.minorversion)
コード例 #7
0
    def test_get_single_object(self, make_req):
        qb_client = client.QuickBooks()
        qb_client.company_id = "1234"

        qb_client.get_single_object("test", 1)
        url = "https://sandbox-quickbooks.api.intuit.com/v3/company/1234/test/1/"
        make_req.assert_called_with("GET", url, {})
コード例 #8
0
 def setUp(self):
     self.qb_client = 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"
     )
コード例 #9
0
    def test_download_pdf_not_authorized(self, process_request):
        qb_client = client.QuickBooks(sandbox=True)
        qb_client.company_id = "1234"
        receipt = SalesReceipt()
        receipt.Id = 1

        process_request.return_value = MockUnauthorizedResponse()

        self.assertRaises(AuthorizationException, receipt.download_pdf,
                          qb_client)
コード例 #10
0
    def test_client_new(self):
        self.qb_client = client.QuickBooks(
            company_id="company_id",
            verbose=True,
            minorversion=4,
            verifier_token=TEST_VERIFIER_TOKEN,
        )

        self.assertEquals(self.qb_client.company_id, "company_id")
        self.assertEquals(self.qb_client.minorversion, 4)
コード例 #11
0
    def setUp(self):
        """
        Use a consistent set of defaults.
        """

        self.qb_client = client.QuickBooks(
            session_manager=MockSessionManager(),
            sandbox=True,
            company_id="update_company_id",
            callback_url="update_callback_url",
            verifier_token=TEST_VERIFIER_TOKEN,
        )
コード例 #12
0
    def setUp(self):
        self.session_manager = Oauth1SessionManager(
            sandbox=True,
            consumer_key="update_consumer_key",
            consumer_secret="update_consumer_secret",
            access_token="update_access_token",
            access_token_secret="update_access_token_secret",
        )

        self.qb_client = client.QuickBooks(
            session_manager=self.session_manager,
            sandbox=True,
            company_id="COMPANY_ID"
        )
コード例 #13
0
    def test_handle_exceptions_severe(self):
        qb_client = client.QuickBooks()
        error_data = {
            "Error": [{
                "Message": "message",
                "Detail": "detail",
                "code": "10001",
                "element": "Id"
            }],
            "type":
            "ValidationFault"
        }

        self.assertRaises(SevereException, qb_client.handle_exceptions,
                          error_data)
コード例 #14
0
    def setUp(self):
        self.qb = client.QuickBooks(
            sandbox=False,
            consumer_key="consumer_key",
            consumer_secret="consumer_secret",
            access_token="access_token",
            access_token_secret="access_token_secret",
            company_id="company_id",
            callback_url="callback_url",
            verbose=True
        )

        self.object1 = Customer()
        self.object2 = Customer()
        self.obj_list = [self.object1, self.object2]
コード例 #15
0
    def test_download_pdf(self, process_request):
        qb_client = client.QuickBooks(sandbox=True)
        qb_client.company_id = "1234"
        receipt = SalesReceipt()
        receipt.Id = 1

        process_request.return_value = MockPdfResponse()

        response = receipt.download_pdf(qb_client)

        url = "https://sandbox-quickbooks.api.intuit.com/v3/company/1234/salesreceipt/1/pdf"
        process_request.assert_called_with(
            "GET",
            url,
            headers={
                'Content-Type': 'application/pdf',
                'Accept': 'application/pdf, application/json',
                'User-Agent': 'python-quickbooks V3 library'
            })

        self.assertEqual(response, 'sample pdf content')
コード例 #16
0
    def test_make_request(self, process_request):
        process_request.return_value = MockResponse()

        qb_client = client.QuickBooks()
        qb_client.company_id = "1234"
        url = "https://sandbox-quickbooks.api.intuit.com/v3/company/1234/test/1/"
        qb_client.make_request("GET",
                               url,
                               request_body=None,
                               content_type='application/json')

        process_request.assert_called_with("GET",
                                           url,
                                           data={},
                                           headers={
                                               'Content-Type':
                                               'application/json',
                                               'Accept':
                                               'application/json',
                                               'User-Agent':
                                               'python-quickbooks V3 library'
                                           },
                                           params={})
コード例 #17
0
    def test_batch_operation(self, make_req):
        qb_client = client.QuickBooks()
        qb_client.batch_operation("request_body")

        self.assertTrue(make_req.called)
コード例 #18
0
    def test_isvalid_object_name_invalid(self):
        qb_client = client.QuickBooks()

        self.assertRaises(Exception, qb_client.isvalid_object_name, "invalid")
コード例 #19
0
    def test_isvalid_object_name_valid(self):
        qb_client = client.QuickBooks()
        result = qb_client.isvalid_object_name("Customer")

        self.assertEquals(result, True)
コード例 #20
0
    def test_api_url_sandbox(self):
        qb_client = client.QuickBooks(sandbox=True)
        api_url = qb_client.api_url

        self.assertTrue("sandbox" in api_url)
コード例 #21
0
    def test_api_url(self):
        qb_client = client.QuickBooks(sandbox=False)
        api_url = qb_client.api_url

        self.assertFalse("sandbox" in api_url)
コード例 #22
0
    def test_misc_operation(self, post):
        qb_client = client.QuickBooks()
        qb_client.misc_operation("end_point", "request_body")

        url = "https://sandbox-quickbooks.api.intuit.com/v3/company/update_company_id/end_point"
        post.assert_called_with(url, "request_body", 'application/json')
コード例 #23
0
 def tearDown(self):
     client.QuickBooks.enable_global()
     self.qb_client = client.QuickBooks()
     self.qb_client._drop()
コード例 #24
0
    def test_query(self, post):
        qb_client = client.QuickBooks()
        qb_client.query("select")

        self.assertTrue(post.called)
コード例 #25
0
    def test_update_object(self, post):
        qb_client = client.QuickBooks()
        qb_client.update_object("Customer", "request_body")

        self.assertTrue(post.called)
コード例 #26
0
    def test_get_instance(self):
        qb_client = client.QuickBooks()

        instance = qb_client.get_instance()
        self.assertEquals(qb_client, instance)