|
| 1 | +import random |
1 | 2 | import uuid
|
| 3 | +from copy import deepcopy |
2 | 4 | from datetime import datetime, timedelta, timezone
|
3 | 5 |
|
4 | 6 | import pytest
|
@@ -459,3 +461,74 @@ async def test_search_line_string_intersects(app_client, ctx):
|
459 | 461 |
|
460 | 462 | resp_json = resp.json()
|
461 | 463 | assert len(resp_json["features"]) == 1
|
| 464 | + |
| 465 | + |
| 466 | +@pytest.mark.asyncio |
| 467 | +@pytest.mark.parametrize( |
| 468 | + "value, expected", |
| 469 | + [ |
| 470 | + (32767, 1), # Short Limit, |
| 471 | + (2147483647, 1), # Int Limit |
| 472 | + (2147483647 + 5000, 1), # Above int Limit |
| 473 | + # All below fail, return three values |
| 474 | + (21474836470, 1), # Above int Limit |
| 475 | + # This value still fails to return 1 |
| 476 | + # Commenting out |
| 477 | + (9223372036854775807, 2), |
| 478 | + ], |
| 479 | +) |
| 480 | +async def test_big_int_eo_search( |
| 481 | + app_client, txn_client, test_item, test_collection, value, expected |
| 482 | +): |
| 483 | + |
| 484 | + random_str = "".join(random.choice("abcdef") for i in range(random.randint(1, 5))) |
| 485 | + collection_id = f"test-collection-eo-{random_str}" |
| 486 | + |
| 487 | + test_big_int_item = test_item |
| 488 | + del test_big_int_item["properties"]["eo:bands"] |
| 489 | + test_big_int_item["collection"] = collection_id |
| 490 | + test_big_int_collection = test_collection |
| 491 | + test_big_int_collection["id"] = collection_id |
| 492 | + |
| 493 | + # type number |
| 494 | + attr = "eo:full_width_half_max" |
| 495 | + |
| 496 | + stac_extensions = [ |
| 497 | + "https://stac-extensions.github.io/eo/v2.0.0/schema.json", |
| 498 | + ] |
| 499 | + |
| 500 | + test_collection["stac_extensions"] = stac_extensions |
| 501 | + |
| 502 | + test_item["stac_extensions"] = stac_extensions |
| 503 | + |
| 504 | + await create_collection(txn_client, test_collection) |
| 505 | + |
| 506 | + for val in [ |
| 507 | + value, |
| 508 | + value + random.randint(10, 1010), |
| 509 | + value - random.randint(10, 1010), |
| 510 | + ]: |
| 511 | + item = deepcopy(test_item) |
| 512 | + item["id"] = str(uuid.uuid4()) |
| 513 | + item["properties"][attr] = val |
| 514 | + await create_item(txn_client, item) |
| 515 | + |
| 516 | + params = { |
| 517 | + "collections": [item["collection"]], |
| 518 | + "filter": { |
| 519 | + "args": [ |
| 520 | + { |
| 521 | + "args": [ |
| 522 | + {"property": f"properties.{attr}"}, |
| 523 | + value, |
| 524 | + ], |
| 525 | + "op": "=", |
| 526 | + } |
| 527 | + ], |
| 528 | + "op": "and", |
| 529 | + }, |
| 530 | + } |
| 531 | + resp = await app_client.post("/search", json=params) |
| 532 | + resp_json = resp.json() |
| 533 | + results = set([x["properties"][attr] for x in resp_json["features"]]) |
| 534 | + assert len(results) == expected |
0 commit comments