Delete tests/test_laya_contract.py with huggingface_hub
Browse files- tests/test_laya_contract.py +0 -53
tests/test_laya_contract.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
| 1 |
-
"""Source and captured-live Laya wire formats, replayed via mock HTTP only."""
|
| 2 |
-
import json
|
| 3 |
-
from pathlib import Path
|
| 4 |
-
|
| 5 |
-
import httpx
|
| 6 |
-
import pytest
|
| 7 |
-
from config.schema import Provider, parse_yaml
|
| 8 |
-
from vrag.providers import Adapter, ProviderFailure
|
| 9 |
-
|
| 10 |
-
@pytest.fixture
|
| 11 |
-
def laya(monkeypatch):
|
| 12 |
-
monkeypatch.setenv('LAYA_URL','https://laya.example')
|
| 13 |
-
monkeypatch.setenv('VM_ALLOWED_HOSTS','laya.example')
|
| 14 |
-
monkeypatch.setattr('socket.getaddrinfo',lambda *a,**k:[(2,1,6,'',('8.8.8.8',443))])
|
| 15 |
-
return Provider(adapter='laya-vision',base_url_env='LAYA_URL',model='thaitea/laya-vision',capabilities=['visual_decision','image_understanding'],trust='approved_sensitive')
|
| 16 |
-
|
| 17 |
-
@pytest.mark.asyncio
|
| 18 |
-
@pytest.mark.parametrize('shape',['source','live'])
|
| 19 |
-
async def test_documented_and_observed_response_shapes(laya,shape):
|
| 20 |
-
response=json.loads((Path(__file__).parent/'fixtures/laya-live-synthetic.json').read_text())
|
| 21 |
-
if shape=='source':response['results']=response['results']['answers']
|
| 22 |
-
def reply(request):
|
| 23 |
-
assert request.url.path=='/v1/system-one'
|
| 24 |
-
body=json.loads(request.content)
|
| 25 |
-
assert body['imageBase64']=='eA=='
|
| 26 |
-
assert 'image' not in body and isinstance(body['state'],dict)
|
| 27 |
-
assert set(body['questions'])=={'visual_signal'}
|
| 28 |
-
return httpx.Response(200,json=response)
|
| 29 |
-
out=await Adapter(httpx.MockTransport(reply)).call('laya',laya,{'image':'data:image/jpeg;base64,eA=='})
|
| 30 |
-
assert not out.detections and not out.text and out.decisions[0].action=='visual_assessment'
|
| 31 |
-
|
| 32 |
-
@pytest.mark.asyncio
|
| 33 |
-
@pytest.mark.parametrize('bad',['placeholder','text_backend','wrong_model','missing_answer','non_probability','wrong_type'])
|
| 34 |
-
async def test_rejects_invalid_or_placeholder_predictions(laya,bad):
|
| 35 |
-
response={'backend':'laya-vision','model':'thaitea/laya-vision','results':{'visual_signal':{'type':'noul','noul':.5}}}
|
| 36 |
-
if bad=='placeholder':response['results']['model']='laya-vision-placeholder'
|
| 37 |
-
if bad=='text_backend':response['backend']='laya'
|
| 38 |
-
if bad=='wrong_model':response['model']='other-model'
|
| 39 |
-
if bad=='missing_answer':response['results']={}
|
| 40 |
-
if bad=='non_probability':response['results']['visual_signal']['noul']=2
|
| 41 |
-
if bad=='wrong_type':response['results']['visual_signal']['type']='choice'
|
| 42 |
-
a=Adapter(httpx.MockTransport(lambda r:httpx.Response(200,json=response)))
|
| 43 |
-
with pytest.raises(ProviderFailure,match='invalid_output'):
|
| 44 |
-
await a.call('laya',laya,{'image':'data:image/jpeg;base64,eA=='})
|
| 45 |
-
|
| 46 |
-
def test_all_shipped_profiles_are_schema_valid():
|
| 47 |
-
for path in (Path(__file__).parent.parent/'config/examples').glob('*.yaml'):
|
| 48 |
-
parse_yaml(path.read_text())
|
| 49 |
-
|
| 50 |
-
def test_image_and_detection_capability_declarations_are_consistent():
|
| 51 |
-
for adapter,capabilities in [('laya-vision',['image_understanding']),('detection-http',['object_tracking'])]:
|
| 52 |
-
with pytest.raises(ValueError):
|
| 53 |
-
Provider(adapter=adapter,base_url_env='URL',model='x',capabilities=capabilities)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|