Robin Claude Sonnet 4.6 commited on
Commit ·
f988bf5
1
Parent(s): b10a07b
test: use ~200-char texts in integration test cases
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tests/test_api_integration.py
CHANGED
|
@@ -41,8 +41,12 @@ def test_health():
|
|
| 41 |
|
| 42 |
def test_extract_person_and_org():
|
| 43 |
payload = {
|
| 44 |
-
"text":
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 48 |
_print("extract person & org", payload, resp, elapsed)
|
|
@@ -59,8 +63,13 @@ def test_extract_person_and_org():
|
|
| 59 |
|
| 60 |
def test_extract_with_high_threshold():
|
| 61 |
payload = {
|
| 62 |
-
"text":
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
"threshold": 0.9,
|
| 65 |
}
|
| 66 |
resp, elapsed = _call("POST", "/extract", payload)
|
|
@@ -72,7 +81,7 @@ def test_extract_with_high_threshold():
|
|
| 72 |
|
| 73 |
|
| 74 |
def test_extract_empty_text_returns_empty():
|
| 75 |
-
payload = {"text": "", "labels": ["person"]}
|
| 76 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 77 |
_print("extract empty text", payload, resp, elapsed)
|
| 78 |
|
|
@@ -81,7 +90,14 @@ def test_extract_empty_text_returns_empty():
|
|
| 81 |
|
| 82 |
|
| 83 |
def test_extract_empty_labels_returns_empty():
|
| 84 |
-
payload = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 86 |
_print("extract empty labels", payload, resp, elapsed)
|
| 87 |
|
|
@@ -90,7 +106,7 @@ def test_extract_empty_labels_returns_empty():
|
|
| 90 |
|
| 91 |
|
| 92 |
def test_extract_invalid_threshold_rejected():
|
| 93 |
-
payload = {"text": "Hello", "labels": ["person"], "threshold": 2.0}
|
| 94 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 95 |
_print("extract invalid threshold", payload, resp, elapsed)
|
| 96 |
|
|
@@ -99,8 +115,13 @@ def test_extract_invalid_threshold_rejected():
|
|
| 99 |
|
| 100 |
def test_entity_fields_present():
|
| 101 |
payload = {
|
| 102 |
-
"text":
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
}
|
| 105 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 106 |
_print("extract field check", payload, resp, elapsed)
|
|
|
|
| 41 |
|
| 42 |
def test_extract_person_and_org():
|
| 43 |
payload = {
|
| 44 |
+
"text": (
|
| 45 |
+
"Elon Musk, the CEO of Tesla and founder of SpaceX, announced a new partnership "
|
| 46 |
+
"with NASA last Tuesday. The deal, signed at Kennedy Space Center in Florida, "
|
| 47 |
+
"will see SpaceX supply rockets for upcoming lunar missions planned by NASA over the next decade."
|
| 48 |
+
),
|
| 49 |
+
"labels": ["person", "organization", "location"],
|
| 50 |
}
|
| 51 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 52 |
_print("extract person & org", payload, resp, elapsed)
|
|
|
|
| 63 |
|
| 64 |
def test_extract_with_high_threshold():
|
| 65 |
payload = {
|
| 66 |
+
"text": (
|
| 67 |
+
"Former US President Barack Obama delivered a keynote speech at the United Nations "
|
| 68 |
+
"headquarters in New York City on Monday, addressing climate change alongside French "
|
| 69 |
+
"President Emmanuel Macron and German Chancellor Olaf Scholz. The event drew leaders "
|
| 70 |
+
"from over fifty countries including Japan, Brazil, and South Africa."
|
| 71 |
+
),
|
| 72 |
+
"labels": ["person", "location", "organization"],
|
| 73 |
"threshold": 0.9,
|
| 74 |
}
|
| 75 |
resp, elapsed = _call("POST", "/extract", payload)
|
|
|
|
| 81 |
|
| 82 |
|
| 83 |
def test_extract_empty_text_returns_empty():
|
| 84 |
+
payload = {"text": "", "labels": ["person", "organization", "location"]}
|
| 85 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 86 |
_print("extract empty text", payload, resp, elapsed)
|
| 87 |
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
def test_extract_empty_labels_returns_empty():
|
| 93 |
+
payload = {
|
| 94 |
+
"text": (
|
| 95 |
+
"Apple Inc. reported record quarterly earnings on Thursday, with CEO Tim Cook "
|
| 96 |
+
"crediting strong iPhone sales in markets across Europe and Southeast Asia. "
|
| 97 |
+
"The company also announced plans to expand its research center in Austin, Texas."
|
| 98 |
+
),
|
| 99 |
+
"labels": [],
|
| 100 |
+
}
|
| 101 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 102 |
_print("extract empty labels", payload, resp, elapsed)
|
| 103 |
|
|
|
|
| 106 |
|
| 107 |
|
| 108 |
def test_extract_invalid_threshold_rejected():
|
| 109 |
+
payload = {"text": "Hello world, this is a simple test sentence.", "labels": ["person"], "threshold": 2.0}
|
| 110 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 111 |
_print("extract invalid threshold", payload, resp, elapsed)
|
| 112 |
|
|
|
|
| 115 |
|
| 116 |
def test_entity_fields_present():
|
| 117 |
payload = {
|
| 118 |
+
"text": (
|
| 119 |
+
"Tim Cook, CEO of Apple, met with Sundar Pichai from Google and Satya Nadella "
|
| 120 |
+
"from Microsoft at a technology summit held in San Francisco last week. The three "
|
| 121 |
+
"executives discussed artificial intelligence regulation and data privacy policies "
|
| 122 |
+
"being proposed by the European Union and the US Congress."
|
| 123 |
+
),
|
| 124 |
+
"labels": ["person", "organization", "location"],
|
| 125 |
}
|
| 126 |
resp, elapsed = _call("POST", "/extract", payload)
|
| 127 |
_print("extract field check", payload, resp, elapsed)
|