Files
mtusi2026lab4/student-tests/outage.py
T

19 lines
930 B
Python

"""Called while the operator has explicitly stopped one dependency."""
import json
from pathlib import Path
import sys
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tests'))
from client import Client
c = Client('http://api1:8080',timeout=40)
c.call('GET','/health/live',schema='Health')
c.call('GET','/health/ready',503)
if sys.argv[1]=='postgres':
c.call('POST','/api/v1/users',503,body={'username':'outage','display_name':'Test','password':'test-password-123'})
else:
a = c.user('outage')
chat = c.call('POST','/api/v1/chats',201,actor=a,body={'title':'S3 outage','member_ids':[a['id']]},schema='Chat')['json']
c.call('POST','/api/v1/chats/'+chat['id']+'/attachments?filename=outage.png',503,actor=a,
raw=Path('tests/fixtures/sample.png').read_bytes(),headers={'Content-Type':'image/png'})
print(json.dumps({'status':'PASS','dependency':sys.argv[1],'live':200,'ready':503,'mutation':503}))