Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /lnbits_lnbits /tests /api /test_webpush_api.py
| from http import HTTPStatus | |
| import pytest | |
| async def test_create___bad_body(client, user_headers_from): | |
| response = await client.post( | |
| "/api/v1/webpush", | |
| headers=user_headers_from, | |
| json={"subscription": "bad_json"}, | |
| ) | |
| assert response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR | |
| async def test_create___missing_fields(client, user_headers_from): | |
| response = await client.post( | |
| "/api/v1/webpush", | |
| headers=user_headers_from, | |
| json={"subscription": """{"a": "x"}"""}, | |
| ) | |
| assert response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR | |
| async def test_create___bad_access_key(client, inkey_headers_from): | |
| response = await client.post( | |
| "/api/v1/webpush", | |
| headers=inkey_headers_from, | |
| json={"subscription": """{"a": "x"}"""}, | |
| ) | |
| assert response.status_code == HTTPStatus.UNAUTHORIZED | |
| async def test_delete__bad_endpoint_format(client, user_headers_from): | |
| response = await client.delete( | |
| "/api/v1/webpush", | |
| params={"endpoint": "https://this.should.be.base64.com"}, | |
| headers=user_headers_from, | |
| ) | |
| assert response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR | |
| async def test_delete__no_endpoint_param(client, user_headers_from): | |
| response = await client.delete( | |
| "/api/v1/webpush", | |
| headers=user_headers_from, | |
| ) | |
| assert response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR | |
| async def test_delete__no_endpoint_found(client, user_headers_from): | |
| response = await client.delete( | |
| "/api/v1/webpush", | |
| params={"endpoint": "aHR0cHM6Ly9kZW1vLmxuYml0cy5jb20="}, | |
| headers=user_headers_from, | |
| ) | |
| assert response.status_code == HTTPStatus.OK | |
| assert response.json()["count"] == 0 | |
| async def test_delete__bad_access_key(client, inkey_headers_from): | |
| response = await client.delete( | |
| "/api/v1/webpush", | |
| headers=inkey_headers_from, | |
| ) | |
| assert response.status_code == HTTPStatus.UNAUTHORIZED | |
| async def test_create_and_delete(client, user_headers_from): | |
| response = await client.post( | |
| "/api/v1/webpush", | |
| headers=user_headers_from, | |
| json={"subscription": """{"endpoint": "https://demo.lnbits.com"}"""}, | |
| ) | |
| assert response.status_code == HTTPStatus.CREATED | |
| response = await client.delete( | |
| "/api/v1/webpush", | |
| params={"endpoint": "aHR0cHM6Ly9kZW1vLmxuYml0cy5jb20="}, | |
| headers=user_headers_from, | |
| ) | |
| assert response.status_code == HTTPStatus.OK | |
| assert response.json()["count"] == 1 | |
Xet Storage Details
- Size:
- 2.71 kB
- Xet hash:
- d619143c7c54f94258b4b95e223f2e3a962d205a4b9f1a61e603591e3cbd3615
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.