Download backend/tests/test_gemini_fallback.py from StillWorking/sentinel-face-recognition: direct link, hf CLI and curl.
- Browser
- Download file 2.74 kB
-
https://huggingface.co/StillWorking/sentinel-face-recognition/resolve/main/backend/tests/test_gemini_fallback.py
- Command line
-
hf download hf://StillWorking/sentinel-face-recognition/backend/tests/test_gemini_fallback.py
-
curl -L -o test_gemini_fallback.py https://huggingface.co/StillWorking/sentinel-face-recognition/resolve/main/backend/tests/test_gemini_fallback.py
2.74 kB
| from core.gemini_agent import _keyword_extract, _keyword_filter, _parse_attributes | |
| def test_female_query_does_not_add_male(): | |
| attrs = _keyword_extract("smiling woman with blond hair") | |
| assert "Male" not in attrs | |
| assert "Smiling" in attrs | |
| assert "Blond_Hair" in attrs | |
| def test_female_query_excludes_male(): | |
| attrs, excluded = _keyword_filter("young smiling woman with blond hair") | |
| assert "Male" not in attrs | |
| assert excluded == ["Male"] | |
| def test_male_query_requires_male_and_does_not_exclude_it(): | |
| attrs, excluded = _keyword_filter("young man with glasses") | |
| assert "Male" in attrs | |
| assert "Eyeglasses" in attrs | |
| assert "Male" not in excluded | |
| def test_no_glasses_is_an_exclusion_not_a_requirement(): | |
| attrs, excluded = _keyword_filter("woman with no glasses") | |
| assert "Eyeglasses" not in attrs | |
| assert "Eyeglasses" in excluded | |
| assert "Male" in excluded | |
| def test_without_a_hat_is_an_exclusion(): | |
| attrs, excluded = _keyword_filter("man without a hat") | |
| assert "Wearing_Hat" not in attrs | |
| assert "Wearing_Hat" in excluded | |
| assert "Male" in attrs | |
| def test_clean_shaven_excludes_facial_hair(): | |
| attrs, excluded = _keyword_filter("clean-shaven man") | |
| assert "No_Beard" in attrs | |
| for attr in ("Mustache", "Goatee", "5_o_Clock_Shadow"): | |
| assert attr in excluded | |
| def test_not_a_man_excludes_male(): | |
| attrs, excluded = _keyword_filter("not a man") | |
| assert "Male" not in attrs | |
| assert "Male" in excluded | |
| def test_old_query_does_not_add_young(): | |
| attrs = _keyword_extract("older person with gray hair and a goatee") | |
| assert "Young" not in attrs | |
| assert "Gray_Hair" in attrs | |
| assert "Goatee" in attrs | |
| def test_beard_is_not_mapped_to_no_beard(): | |
| attrs = _keyword_extract("person with beard and mustache") | |
| assert "No_Beard" not in attrs | |
| assert "Mustache" in attrs | |
| def test_explicit_no_beard_is_kept(): | |
| attrs = _keyword_extract("beardless young man") | |
| assert "No_Beard" in attrs | |
| assert "Young" in attrs | |
| assert "Male" in attrs | |
| def test_parse_accepts_bare_array(): | |
| assert _parse_attributes('["Male", "Eyeglasses"]') == ["Male", "Eyeglasses"] | |
| def test_parse_accepts_object_and_normalises_case(): | |
| assert _parse_attributes('{"attributes": ["male", "BLACK_HAIR"]}') == [ | |
| "Male", | |
| "Black_Hair", | |
| ] | |
| def test_parse_strips_code_fences(): | |
| assert _parse_attributes('```json\n["Young", "Smiling"]\n```') == [ | |
| "Young", | |
| "Smiling", | |
| ] | |
| def test_parse_rejects_unknown_attributes(): | |
| assert _parse_attributes('["Male", "Wings", "Smiling"]') == ["Male", "Smiling"] | |
| def test_parse_garbage_returns_empty(): | |
| assert _parse_attributes("I cannot help with that.") == [] | |