|
10 | 10 | from weaviate.exceptions import SchemaValidationException |
11 | 11 | from weaviate.util import ( |
12 | 12 | MINIMUM_NO_WARNING_VERSION, |
| 13 | + _capitalize_first_letter, |
13 | 14 | _datetime_from_weaviate_str, |
14 | 15 | _is_sub_schema, |
15 | 16 | _sanitize_str, |
|
21 | 22 | image_encoder_b64, |
22 | 23 | is_object_url, |
23 | 24 | is_weaviate_client_too_old, |
| 25 | + is_weaviate_domain, |
24 | 26 | is_weaviate_object_url, |
25 | 27 | is_weaviate_too_old, |
26 | 28 | parse_version_string, |
| 29 | + strip_newlines, |
27 | 30 | ) |
28 | 31 |
|
29 | 32 | schema_set = { |
@@ -495,3 +498,52 @@ def test_is_weaviate_client_too_old(current_version: str, latest_version: str, t |
495 | 498 | ) |
496 | 499 | def test_sanitize_str(in_str: str, out_str: str) -> None: |
497 | 500 | assert _sanitize_str(in_str) == f'"{out_str}"' |
| 501 | + |
| 502 | + |
| 503 | +@pytest.mark.parametrize( |
| 504 | + "value,expected", |
| 505 | + [ |
| 506 | + ("", ""), |
| 507 | + ("a", "A"), |
| 508 | + ("z", "Z"), |
| 509 | + ("hi", "Hi"), |
| 510 | + # Only the first character is touched; the remainder is left as-is. |
| 511 | + ("hELLO", "HELLO"), |
| 512 | + ("Hello", "Hello"), |
| 513 | + ("1abc", "1abc"), |
| 514 | + ], |
| 515 | +) |
| 516 | +def test_capitalize_first_letter(value: str, expected: str) -> None: |
| 517 | + assert _capitalize_first_letter(value) == expected |
| 518 | + |
| 519 | + |
| 520 | +@pytest.mark.parametrize( |
| 521 | + "url,expected", |
| 522 | + [ |
| 523 | + ("https://my-cluster.weaviate.io", True), |
| 524 | + ("https://my-cluster.weaviate.cloud", True), |
| 525 | + ("https://foo.semi.technology", True), |
| 526 | + # Matching is case-insensitive. |
| 527 | + ("https://MY-CLUSTER.WEAVIATE.CLOUD", True), |
| 528 | + ("http://localhost:8080", False), |
| 529 | + ("https://example.com", False), |
| 530 | + ("", False), |
| 531 | + ], |
| 532 | +) |
| 533 | +def test_is_weaviate_domain(url: str, expected: bool) -> None: |
| 534 | + assert is_weaviate_domain(url) is expected |
| 535 | + |
| 536 | + |
| 537 | +@pytest.mark.parametrize( |
| 538 | + "value,expected", |
| 539 | + [ |
| 540 | + ("no newlines", "no newlines"), |
| 541 | + ("one\nnewline", "one newline"), |
| 542 | + ("a\nb\nc", "a b c"), |
| 543 | + ("\nleading", " leading"), |
| 544 | + ("trailing\n", "trailing "), |
| 545 | + ("", ""), |
| 546 | + ], |
| 547 | +) |
| 548 | +def test_strip_newlines(value: str, expected: str) -> None: |
| 549 | + assert strip_newlines(value) == expected |
0 commit comments