当前位置: 首页>>代码示例>>Python>>正文


Python Document.validate方法代码示例

本文整理汇总了Python中pyavatax.base.Document.validate方法的典型用法代码示例。如果您正苦于以下问题:Python Document.validate方法的具体用法?Python Document.validate怎么用?Python Document.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyavatax.base.Document的用法示例。


在下文中一共展示了Document.validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_validation

# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import validate [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
开发者ID:kgrinberg,项目名称:pyavatax,代码行数:56,代码来源:test_avalara.py

示例2: test_validation

# 需要导入模块: from pyavatax.base import Document [as 别名]
# 或者: from pyavatax.base.Document import validate [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
开发者ID:activefrequency,项目名称:pyavatax,代码行数:44,代码来源:test_avalara.py


注:本文中的pyavatax.base.Document.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。