-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from avadev/SDK_bug_fixes
MR : fixed AS-134 and AS-135
- Loading branch information
Showing
8 changed files
with
282 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"""Conftest is a file recognize by pytest module, allowing us to share fixture across multiple tests.""" | ||
from avalara import AvataxClient | ||
from avalara.transaction_builder import TransactionBuilder | ||
from src.avalara import AvataxClient | ||
from src.avalara.transaction_builder import TransactionBuilder | ||
import os | ||
import pytest | ||
|
||
|
@@ -53,7 +53,7 @@ def ship_from_address(): | |
'line1': '123 Main Street', | ||
'city': 'Irvine', | ||
'region': 'CA', | ||
'postalCode': '92615' | ||
'postalCode': '92615', | ||
} | ||
return address | ||
|
||
|
@@ -95,29 +95,38 @@ def five_transactions(): | |
('Poulsbo', '200 Moe St Ne', '98370', 'WA'), | ||
('Los Angeles', '1945 S Hill St', '90007', 'CA'), | ||
('Chicago', '50 W Washington St', '60602', 'IL'), | ||
('Irvine', '123 Main Street', '92615', 'CA') | ||
('Irvine', '123 Main Street', '92615', 'CA'), | ||
] | ||
for city, line1, postal, region in addresses: | ||
tax_document = { | ||
'addresses': {'SingleLocation': {'city': city, | ||
'country': 'US', | ||
'line1': line1, | ||
'postalCode': postal, | ||
'region': region}}, | ||
'addresses': { | ||
'SingleLocation': { | ||
'city': city, | ||
'country': 'US', | ||
'line1': line1, | ||
'postalCode': postal, | ||
'region': region, | ||
} | ||
}, | ||
'commit': False, | ||
'companyCode': 'DEFAULT', | ||
'currencyCode': 'USD', | ||
'customerCode': 'ABC', | ||
'date': '2017-04-12', | ||
'description': 'Yarn', | ||
'lines': [{'amount': 100, | ||
'description': 'Yarn', | ||
'itemCode': 'Y0001', | ||
'number': '1', | ||
'quantity': 1, | ||
'taxCode': 'PS081282'}], | ||
'lines': [ | ||
{ | ||
'amount': 100, | ||
'description': 'Yarn', | ||
'itemCode': 'Y0001', | ||
'number': '1', | ||
'quantity': 1, | ||
'taxCode': 'PS081282', | ||
} | ||
], | ||
'purchaseOrderNo': '2017-04-12-001', | ||
'type': 'SalesInvoice'} | ||
'type': 'SalesInvoice', | ||
} | ||
r = client.create_transaction(tax_document, None) | ||
trans_codes.append(r.json()['code']) | ||
return trans_codes | ||
|
@@ -128,6 +137,7 @@ def tax_document(): | |
"""Create a tax document dictionary.""" | ||
return default_trans_model() | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def init_comp_model(): | ||
"""Return the following initialize company model for company DEFAULT.""" | ||
|
@@ -145,41 +155,64 @@ def init_comp_model(): | |
"title": "Owner", | ||
"email": "[email protected]", | ||
"phoneNumber": "714 555-2121", | ||
"mobileNumber": "714 555-1212"} | ||
"mobileNumber": "714 555-1212", | ||
} | ||
|
||
|
||
def cred_determine(): | ||
"""Return the appropriate pair of cred.""" | ||
if os.environ.get('USERNAME') and os.environ.get('PASSWORD'): | ||
return (os.environ.get('USERNAME'), os.environ.get('PASSWORD')) | ||
elif os.environ.get('SANDBOX_CLIENTID') and os.environ.get('SANDBOX_LICENSEKEY'): | ||
return (os.environ.get('SANDBOX_CLIENTID'), os.environ.get('SANDBOX_LICENSEKEY')) | ||
elif os.environ.get('SANDBOX_USERNAME') and os.environ.get('SANDBOX_PASSWORD'): | ||
return (os.environ.get('SANDBOX_USERNAME'), os.environ.get('SANDBOX_PASSWORD')) | ||
elif os.environ.get('SANDBOX_CLIENTID') and os.environ.get( | ||
'SANDBOX_LICENSEKEY' | ||
): | ||
return ( | ||
os.environ.get('SANDBOX_CLIENTID'), | ||
os.environ.get('SANDBOX_LICENSEKEY'), | ||
) | ||
elif os.environ.get('SANDBOX_USERNAME') and os.environ.get( | ||
'SANDBOX_PASSWORD' | ||
): | ||
return ( | ||
os.environ.get('SANDBOX_USERNAME'), | ||
os.environ.get('SANDBOX_PASSWORD'), | ||
) | ||
else: | ||
raise ValueError() | ||
|
||
|
||
def default_trans_model(): | ||
"""Return the default transaction model.""" | ||
return { | ||
'addresses': {'SingleLocation': {'city': 'Irvine', | ||
'country': 'US', | ||
'line1': '123 Main Street', | ||
'postalCode': '92615', | ||
'region': 'CA'}}, | ||
'addresses': { | ||
'SingleLocation': { | ||
'city': 'Irvine', | ||
'country': 'US', | ||
'line1': '123 Main Street', | ||
'postalCode': '92615', | ||
'region': 'CA', | ||
} | ||
}, | ||
'commit': False, | ||
'companyCode': 'DEFAULT', | ||
'currencyCode': 'USD', | ||
'customerCode': 'ABC', | ||
'date': '2017-04-12', | ||
'description': 'Yarn', | ||
'lines': [{'amount': 100, | ||
'description': 'Yarn', | ||
'itemCode': 'Y0001', | ||
'number': '1', | ||
'quantity': 1, | ||
'taxCode': 'PS081282'}], | ||
'lines': [ | ||
{ | ||
'amount': 100, | ||
'description': 'Yarn', | ||
'itemCode': 'Y0001', | ||
'number': '1', | ||
'quantity': 1, | ||
'taxCode': 'PS081282', | ||
} | ||
], | ||
'purchaseOrderNo': '2017-04-12-001', | ||
'type': 'SalesInvoice'} | ||
'type': 'SalesInvoice', | ||
} | ||
|
||
|
||
def pytest_runtest_makereport(item, call): | ||
"""For incremental testing fixture called mark.increment.""" | ||
|
@@ -188,11 +221,10 @@ def pytest_runtest_makereport(item, call): | |
parent = item.parent | ||
parent._previousfailed = item | ||
|
||
|
||
def pytest_runtest_setup(item): | ||
"""For incremental testing fixture called mark.increment.""" | ||
if "incremental" in item.keywords: | ||
previousfailed = getattr(item.parent, "_previousfailed", None) | ||
if previousfailed is not None: | ||
pytest.xfail("previous test failed (%s)" %previousfailed.name) | ||
|
||
|
||
pytest.xfail("previous test failed (%s)" % previousfailed.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.