def setUp(self):
        self.session_manager = Oauth1SessionManager(
            sandbox=True,
            consumer_key=os.environ.get('CONSUMER_KEY'),
            consumer_secret=os.environ.get('CONSUMER_SECRET'),
            access_token=os.environ.get('ACCESS_TOKEN'),
            access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'),
        )

        self.qb_client = QuickBooks(session_manager=self.session_manager,
                                    sandbox=True,
                                    company_id=os.environ.get('COMPANY_ID'))

        self.name = "TaxCode {0}".format(datetime.now().strftime('%d%H%M'))
Example #2
0
    def setUp(self):
        self.session_manager = Oauth1SessionManager(
            sandbox=True,
            consumer_key=os.environ.get('CONSUMER_KEY'),
            consumer_secret=os.environ.get('CONSUMER_SECRET'),
            access_token=os.environ.get('ACCESS_TOKEN'),
            access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'),
        )

        self.qb_client = QuickBooks(
            session_manager=self.session_manager,
            sandbox=True,
            company_id=os.environ.get('COMPANY_ID')
        )
    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"
        )
Example #4
0
    def test_start_session_no_access_token(self):
        session_manager = Oauth1SessionManager(
            consumer_key='key',
            consumer_secret='secret',
            access_token='',
            access_token_secret='tokensecret',
        )

        try:
            with self.assertRaises(QuickbooksException) as error:
                session_manager.start_session()

            self.assertEqual(error.exception.message,
                             "Access Token missing. Cannot create session.")
        except:
            self.failUnlessRaises(QuickbooksException, session_manager.start_session)

        self.assertEqual(session_manager.started, False)
    def get_oauth_1(self):
        self._set_headers()
        qb_data = self.server.qb_data

        GET = parse_qs(urlparse(self.path).query)

        oauth_verifier = GET.get('oauth_verifier')
        realm_id = GET.get('realmId')

        if type(realm_id) is list and len(realm_id) == 1:
            realm_id = realm_id[0]

        if oauth_verifier and realm_id:
            client = Oauth1SessionManager(
                sandbox=qb_data['sandbox'],
                consumer_key=qb_data['consumer_key'],
                consumer_secret=qb_data['consumer_secret'])

            client.authorize_url = qb_data['authorize_url']
            client.request_token = qb_data['request_token']
            client.request_token_secret = qb_data['request_token_secret']
            client.get_access_tokens(oauth_verifier)

            self.wfile.write(
                bytes('<h1>QuickBooks auth handled with success!</h1>',
                      'UTF-8'))
            self.wfile.write(
                bytes('<p><b>Sandbox:</b> {0}</p>'.format(qb_data['sandbox']),
                      'UTF-8'))
            self.wfile.write(
                bytes('<p><b>Realm Id:</b> {0}</p>'.format(realm_id), 'UTF-8'))

            self.wfile.write(
                bytes(
                    '<p><b>Access Token:</b> {0}</p>'.format(
                        client.access_token), 'UTF-8'))
            self.wfile.write(
                bytes(
                    '<p><b>Access Token Secret:</b> {0}</p>'.format(
                        client.access_token_secret), 'UTF-8'))
        else:
            self.wfile.write(
                bytes('<h1>QuickBooks auth failed, try again.</h1>', 'UTF-8'))
    def setUp(self):
        self.session_manager = Oauth1SessionManager(
            sandbox=True,
            consumer_key=os.environ.get('CONSUMER_KEY'),
            consumer_secret=os.environ.get('CONSUMER_SECRET'),
            access_token=os.environ.get('ACCESS_TOKEN'),
            access_token_secret=os.environ.get('ACCESS_TOKEN_SECRET'),
        )

        self.qb_client = QuickBooks(session_manager=self.session_manager,
                                    sandbox=True,
                                    company_id=os.environ.get('COMPANY_ID'))

        self.title = "Mr"
        self.given_name = "James"
        self.middle_name = "B"
        self.family_name = "King"
        self.suffix = "Jr"
        self.fully_qualified_name = datetime.now().strftime('%d%H%M%S')
        self.company_name = datetime.now().strftime('%d%H%M%S')
        self.display_name = datetime.now().strftime('%d%H%M%S')