Spaces:
Configuration error
Configuration error
Commit
·
3ec2cfd
1
Parent(s):
410407a
Updated tests of get_processed_data() function
Browse files- tests/test_gradio.py +28 -12
tests/test_gradio.py
CHANGED
|
@@ -233,12 +233,14 @@ class TestGetProcessedData(unittest.TestCase):
|
|
| 233 |
result = gradio.get_processed_data(
|
| 234 |
mock_pdf,
|
| 235 |
"https://github.com/user",
|
| 236 |
-
"Job posting content"
|
|
|
|
| 237 |
)
|
| 238 |
|
| 239 |
self.assertEqual(result["linkedin"], mock_linkedin_result)
|
| 240 |
self.assertEqual(result["github"], mock_github_result)
|
| 241 |
self.assertEqual(result["job_post"], "Job posting content")
|
|
|
|
| 242 |
self.assertEqual(len(result["errors"]), 0)
|
| 243 |
|
| 244 |
def test_linkedin_error(self):
|
|
@@ -252,7 +254,7 @@ class TestGetProcessedData(unittest.TestCase):
|
|
| 252 |
"message": "PDF read failed"
|
| 253 |
}
|
| 254 |
|
| 255 |
-
result = gradio.get_processed_data(mock_pdf, "", "")
|
| 256 |
|
| 257 |
self.assertIsNone(result["linkedin"])
|
| 258 |
self.assertEqual(len(result["errors"]), 1)
|
|
@@ -266,7 +268,7 @@ class TestGetProcessedData(unittest.TestCase):
|
|
| 266 |
"message": "User not found"
|
| 267 |
}
|
| 268 |
|
| 269 |
-
result = gradio.get_processed_data(None, "https://github.com/invalid", "")
|
| 270 |
|
| 271 |
self.assertIsNone(result["github"])
|
| 272 |
self.assertEqual(len(result["errors"]), 1)
|
|
@@ -292,6 +294,7 @@ class TestGetProcessedData(unittest.TestCase):
|
|
| 292 |
result = gradio.get_processed_data(
|
| 293 |
mock_pdf,
|
| 294 |
"https://github.com/user",
|
|
|
|
| 295 |
""
|
| 296 |
)
|
| 297 |
|
|
@@ -304,15 +307,15 @@ class TestGetProcessedData(unittest.TestCase):
|
|
| 304 |
def test_job_post_whitespace_handling(self):
|
| 305 |
"""Test job post whitespace handling."""
|
| 306 |
# Test with leading/trailing whitespace
|
| 307 |
-
result = gradio.get_processed_data(None, "", " Job content ")
|
| 308 |
self.assertEqual(result["job_post"], "Job content")
|
| 309 |
|
| 310 |
# Test with only whitespace
|
| 311 |
-
result = gradio.get_processed_data(None, "", " ")
|
| 312 |
self.assertIsNone(result["job_post"])
|
| 313 |
|
| 314 |
# Test with empty string
|
| 315 |
-
result = gradio.get_processed_data(None, "", "")
|
| 316 |
self.assertIsNone(result["job_post"])
|
| 317 |
|
| 318 |
def test_github_url_whitespace_handling(self):
|
|
@@ -321,20 +324,20 @@ class TestGetProcessedData(unittest.TestCase):
|
|
| 321 |
mock_github.return_value = {"status": "success", "repositories": []}
|
| 322 |
|
| 323 |
# Test with leading/trailing whitespace
|
| 324 |
-
result = gradio.get_processed_data(None, " https://github.com/user ", "")
|
| 325 |
mock_github.assert_called_with(" https://github.com/user ")
|
| 326 |
|
| 327 |
# Test with only whitespace - should not call function
|
| 328 |
mock_github.reset_mock()
|
| 329 |
-
result = gradio.get_processed_data(None, " ", "")
|
| 330 |
mock_github.assert_not_called()
|
| 331 |
|
| 332 |
def test_data_structure_consistency(self):
|
| 333 |
"""Test that returned data structure is consistent."""
|
| 334 |
-
result = gradio.get_processed_data(None, "", "")
|
| 335 |
|
| 336 |
# Check all required keys exist
|
| 337 |
-
required_keys = ["linkedin", "github", "job_post", "errors"]
|
| 338 |
for key in required_keys:
|
| 339 |
self.assertIn(key, result)
|
| 340 |
|
|
@@ -352,13 +355,26 @@ class TestGetProcessedData(unittest.TestCase):
|
|
| 352 |
"message": "Some warning"
|
| 353 |
}
|
| 354 |
|
| 355 |
-
result = gradio.get_processed_data(mock_pdf, "", "")
|
| 356 |
|
| 357 |
# Warning status should not be treated as success
|
| 358 |
self.assertIsNone(result["linkedin"])
|
| 359 |
self.assertEqual(len(result["errors"]), 1)
|
| 360 |
self.assertIn("LinkedIn: Some warning", result["errors"])
|
| 361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
|
| 363 |
if __name__ == '__main__':
|
| 364 |
unittest.main()
|
|
|
|
| 233 |
result = gradio.get_processed_data(
|
| 234 |
mock_pdf,
|
| 235 |
"https://github.com/user",
|
| 236 |
+
"Job posting content",
|
| 237 |
+
"Custom instructions"
|
| 238 |
)
|
| 239 |
|
| 240 |
self.assertEqual(result["linkedin"], mock_linkedin_result)
|
| 241 |
self.assertEqual(result["github"], mock_github_result)
|
| 242 |
self.assertEqual(result["job_post"], "Job posting content")
|
| 243 |
+
self.assertEqual(result["user_instructions"], "Custom instructions")
|
| 244 |
self.assertEqual(len(result["errors"]), 0)
|
| 245 |
|
| 246 |
def test_linkedin_error(self):
|
|
|
|
| 254 |
"message": "PDF read failed"
|
| 255 |
}
|
| 256 |
|
| 257 |
+
result = gradio.get_processed_data(mock_pdf, "", "", "")
|
| 258 |
|
| 259 |
self.assertIsNone(result["linkedin"])
|
| 260 |
self.assertEqual(len(result["errors"]), 1)
|
|
|
|
| 268 |
"message": "User not found"
|
| 269 |
}
|
| 270 |
|
| 271 |
+
result = gradio.get_processed_data(None, "https://github.com/invalid", "", "")
|
| 272 |
|
| 273 |
self.assertIsNone(result["github"])
|
| 274 |
self.assertEqual(len(result["errors"]), 1)
|
|
|
|
| 294 |
result = gradio.get_processed_data(
|
| 295 |
mock_pdf,
|
| 296 |
"https://github.com/user",
|
| 297 |
+
"",
|
| 298 |
""
|
| 299 |
)
|
| 300 |
|
|
|
|
| 307 |
def test_job_post_whitespace_handling(self):
|
| 308 |
"""Test job post whitespace handling."""
|
| 309 |
# Test with leading/trailing whitespace
|
| 310 |
+
result = gradio.get_processed_data(None, "", " Job content ", "")
|
| 311 |
self.assertEqual(result["job_post"], "Job content")
|
| 312 |
|
| 313 |
# Test with only whitespace
|
| 314 |
+
result = gradio.get_processed_data(None, "", " ", "")
|
| 315 |
self.assertIsNone(result["job_post"])
|
| 316 |
|
| 317 |
# Test with empty string
|
| 318 |
+
result = gradio.get_processed_data(None, "", "", "")
|
| 319 |
self.assertIsNone(result["job_post"])
|
| 320 |
|
| 321 |
def test_github_url_whitespace_handling(self):
|
|
|
|
| 324 |
mock_github.return_value = {"status": "success", "repositories": []}
|
| 325 |
|
| 326 |
# Test with leading/trailing whitespace
|
| 327 |
+
result = gradio.get_processed_data(None, " https://github.com/user ", "", "")
|
| 328 |
mock_github.assert_called_with(" https://github.com/user ")
|
| 329 |
|
| 330 |
# Test with only whitespace - should not call function
|
| 331 |
mock_github.reset_mock()
|
| 332 |
+
result = gradio.get_processed_data(None, " ", "", "")
|
| 333 |
mock_github.assert_not_called()
|
| 334 |
|
| 335 |
def test_data_structure_consistency(self):
|
| 336 |
"""Test that returned data structure is consistent."""
|
| 337 |
+
result = gradio.get_processed_data(None, "", "", "")
|
| 338 |
|
| 339 |
# Check all required keys exist
|
| 340 |
+
required_keys = ["linkedin", "github", "job_post", "user_instructions", "errors"]
|
| 341 |
for key in required_keys:
|
| 342 |
self.assertIn(key, result)
|
| 343 |
|
|
|
|
| 355 |
"message": "Some warning"
|
| 356 |
}
|
| 357 |
|
| 358 |
+
result = gradio.get_processed_data(mock_pdf, "", "", "")
|
| 359 |
|
| 360 |
# Warning status should not be treated as success
|
| 361 |
self.assertIsNone(result["linkedin"])
|
| 362 |
self.assertEqual(len(result["errors"]), 1)
|
| 363 |
self.assertIn("LinkedIn: Some warning", result["errors"])
|
| 364 |
+
|
| 365 |
+
def test_user_instructions_whitespace_handling(self):
|
| 366 |
+
"""Test user instructions whitespace handling."""
|
| 367 |
+
# Test with leading/trailing whitespace
|
| 368 |
+
result = gradio.get_processed_data(None, "", "", " Custom instructions ")
|
| 369 |
+
self.assertEqual(result["user_instructions"], "Custom instructions")
|
| 370 |
+
|
| 371 |
+
# Test with only whitespace
|
| 372 |
+
result = gradio.get_processed_data(None, "", "", " ")
|
| 373 |
+
self.assertIsNone(result["user_instructions"])
|
| 374 |
+
|
| 375 |
+
# Test with empty string
|
| 376 |
+
result = gradio.get_processed_data(None, "", "", "")
|
| 377 |
+
self.assertIsNone(result["user_instructions"])
|
| 378 |
|
| 379 |
if __name__ == '__main__':
|
| 380 |
unittest.main()
|