本文整理汇总了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)
示例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)