Spaces:
Running
Running
| import pytest | |
| def test_empty_string_returns_400(client, prediction_payload, auth_headers, model): | |
| response = client.post("/predict", json=prediction_payload("", model), headers=auth_headers) | |
| assert response.status_code==400 | |
| def test_whitespace_only_returns_400(client, prediction_payload, auth_headers, model): | |
| response = client.post("/predict", json=prediction_payload(" ", model), headers=auth_headers) | |
| assert response.status_code==400 | |
| def test_single_character_input(client, prediction_payload, auth_headers, model): | |
| response = client.post("/predict", json=prediction_payload("a", model), headers=auth_headers) | |
| assert response.status_code==200 | |
| def test_very_long_input_10000_chars(client, prediction_payload, auth_headers, model): | |
| text = ("The quick brown fox jumps over the lazy dog. " * 223)[:10000] | |
| response = client.post("/predict", json=prediction_payload(text, model), headers=auth_headers) | |
| assert response.status_code==200 | |
| def test_unicode_input(client, prediction_payload, auth_headers, model): | |
| if model=="Bi-LSTM": | |
| response = client.post("/predict", json=prediction_payload("ใใใซใกใฏ", model), headers=auth_headers) | |
| assert response.status_code==400 | |
| else: | |
| response = client.post("/predict", json=prediction_payload("ใใใซใกใฏ", model), headers=auth_headers) | |
| assert response.status_code==200 | |
| def test_emoji_only_input(client, prediction_payload, auth_headers, model): | |
| if model=="Bi-LSTM": | |
| response = client.post("/predict", json=prediction_payload("๐๐๐๐๐๐๐", model), headers=auth_headers) | |
| assert response.status_code==400 | |
| else: | |
| response = client.post("/predict", json=prediction_payload("๐๐๐๐๐๐๐", model), headers=auth_headers) | |
| assert response.status_code==200 | |
| def test_numbers_only_input(client, prediction_payload, auth_headers, model): | |
| response = client.post("/predict", json=prediction_payload("990011226688173638 628349349 38298048207422", model), headers=auth_headers) | |
| assert response.status_code==200 | |
| def test_special_characters_only_input(client, prediction_payload, auth_headers, model): | |
| if model=="Bi-LSTM": | |
| response = client.post("/predict", json=prediction_payload("-=['/.,;@(!*#&( (@&( @* (!@*( @@@#:< >)[']", model), headers=auth_headers) | |
| assert response.status_code==400 | |
| else: | |
| response = client.post("/predict", json=prediction_payload("-=['/.,;@(!*#&( (@&( @* (!@*( @@@#:< >)[']", model), headers=auth_headers) | |
| assert response.status_code==200 | |
| def test_mixed_languages_input(client, prediction_payload, auth_headers, model): | |
| response = client.post("/predict", json=prediction_payload("ใใใซใกใฏ Awesome เคจเคฎเคธเฅเคคเฅ ไฝ ๅฅฝ", model), headers=auth_headers) | |
| assert response.status_code==200 | |
| def test_newlines_and_tabs_input(client, prediction_payload, auth_headers, model): | |
| response = client.post("/predict", json=prediction_payload("First line.\nSecond line.\tIndented text.", model), headers=auth_headers) | |
| assert response.status_code==200 |