本文整理汇总了Python中pyavatax.base.Document.add_from_address方法的典型用法代码示例。如果您正苦于以下问题:Python Document.add_from_address方法的具体用法?Python Document.add_from_address怎么用?Python Document.add_from_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyavatax.base.Document
的用法示例。
在下文中一共展示了Document.add_from_address方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validation
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import add_from_address [as 别名]
def test_validation():
try:
doc = Document(DocDate='foo') # testing date
except AvalaraException:
assert True
else:
assert False
try:
doc = Line(Qty='foo') # testing int
except AvalaraException:
assert True
else:
assert False
try:
doc = Line(Amount='foo') # testing float
except AvalaraException:
assert True
else:
assert False
doc = Document.new_sales_order(DocCode='1001', DocDate=datetime.date.today(), CustomerCode='[email protected]')
try:
doc.validate()
except AvalaraException:
assert True
else:
assert False
from_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
to_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
doc.add_from_address(from_address)
doc.add_to_address(to_address)
try:
doc.validate()
except AvalaraException:
assert True
else:
assert False
try:
doc.add_from_address(from_address)
except AvalaraException:
assert True
else:
assert False
try:
doc.add_to_address(from_address)
except AvalaraException:
assert True
else:
assert False
line = Line(Amount=10.00)
doc.add_line(line)
try:
doc.validate()
except AvalaraException:
assert False
示例2: test_validation
# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import add_from_address [as 别名]
def test_validation():
with pytest.raises(AvalaraValidationException) as e:
doc = Document(DocDate='foo') # testing date
assert e.value.code == AvalaraException.CODE_BAD_DATE
with pytest.raises(AvalaraValidationException) as e:
line = Line(Qty='foo') # testing int
assert e.value.code == AvalaraException.CODE_BAD_FLOAT
with pytest.raises(AvalaraValidationException) as e:
line = Line(Amount='foo') # testing float
assert e.value.code == AvalaraException.CODE_BAD_FLOAT
with pytest.raises(AvalaraValidationException) as e:
line = Line(ItemCode='this string is longer than fifty characters and should be stopped') # testing length
assert e.value.code == AvalaraException.CODE_TOO_LONG
doc = Document.new_sales_order(DocCode='1001', DocDate=datetime.date.today(), CustomerCode='[email protected]')
with pytest.raises(AvalaraValidationException) as e:
doc.validate()
assert e.value.code == AvalaraException.CODE_BAD_ADDRESS
from_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
to_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
doc.add_from_address(from_address)
doc.add_to_address(to_address)
with pytest.raises(AvalaraValidationException) as e:
doc.validate()
assert e.value.code == AvalaraException.CODE_BAD_LINE
with pytest.raises(AvalaraException) as e:
doc.add_from_address(from_address)
assert e.value.code == AvalaraException.CODE_HAS_FROM
with pytest.raises(AvalaraException) as e:
doc.add_to_address(to_address)
assert e.value.code == AvalaraException.CODE_HAS_TO
line = Line(Amount=10.00)
doc.add_line(line)
doc.validate()
api = get_api()
lat = 47.627935
lng = -122.51702
with pytest.raises(AvalaraTypeException) as e:
api.get_tax(lat, lng, 'foo', None)
assert e.value.code == AvalaraException.CODE_BAD_DOC
with pytest.raises(AvalaraException) as e:
api.get_tax(lat, lng, None, None)
assert e.value.code == AvalaraException.CODE_BAD_ARGS