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


Python SentinelAPI.check_query_length方法代码示例

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


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

示例1: test_too_long_query

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import check_query_length [as 别名]
def test_too_long_query(api):
    # Test whether our limit calculation is reasonably correct and
    # that a relevant error message is provided

    def create_query(n):
        return " a_-.*:,?+~!" * n

    # Expect no error
    q = create_query(163)
    assert 0.99 < SentinelAPI.check_query_length(q) < 1.0
    with pytest.raises(SentinelAPIError) as excinfo:
        api.count(raw=q)
    assert "Invalid query string" in excinfo.value.msg

    # Expect HTTP status 500 Internal Server Error
    q = create_query(164)
    assert 0.999 <= SentinelAPI.check_query_length(q) < 1.01
    with pytest.raises(SentinelAPIError) as excinfo:
        api.count(raw=q)
    assert excinfo.value.response.status_code == 500
    assert ("Request Entity Too Large" in excinfo.value.msg or
            "Request-URI Too Long" in excinfo.value.msg)
开发者ID:valgur,项目名称:sentinelsat,代码行数:24,代码来源:test_mod.py

示例2: test_too_long_query

# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import check_query_length [as 别名]
def test_too_long_query():
    api = SentinelAPI(**_api_kwargs)

    # Test whether our limit calculation is reasonably correct and
    # that a relevant error message is provided

    def create_query(n):
        return api.format_query(date=("NOW", "NOW"), raw=" abc_:*.+*~!," * n)

    # Expect no error
    q = create_query(170)
    assert 0.99 < SentinelAPI.check_query_length(q) < 1.0
    with pytest.raises(SentinelAPIError) as excinfo:
        api.query(raw=q)
    assert "Invalid query string" in excinfo.value.msg

    # Expect HTTP status 500 Internal Server Error
    q = create_query(171)
    assert 1.0 <= SentinelAPI.check_query_length(q) < 1.01
    with pytest.raises(SentinelAPIError) as excinfo:
        api.query(raw=q)
    assert excinfo.value.response.status_code == 500
    assert ("Request Entity Too Large" in excinfo.value.msg or
            "Request-URI Too Long" in excinfo.value.msg)
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:26,代码来源:test_mod.py


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