Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ sanic
aiohttp
Pillow
requests
Flask
flask
2 changes: 1 addition & 1 deletion samples/http-image-cloudevents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pip3 install -r requirements.txt
Start server:

```sh
python3 server.py
python3 image_sample_server.py
```

In a new shell, run the client code which sends a structured and binary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import pytest
from client import image_bytes
from image_sample_server import app
from PIL import Image
from server import app

from cloudevents.http import (
CloudEvent,
Expand Down
8 changes: 7 additions & 1 deletion samples/http-json-cloudevents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pip3 install -r requirements.txt
Start server:

```sh
python3 server.py
python3 json_sample_server.py
```

In a new shell, run the client code which sends a structured and binary
Expand All @@ -18,3 +18,9 @@ cloudevent to your local server:
```sh
python3 client.py http://localhost:3000/
```

## Test

```sh
pytest
```
40 changes: 40 additions & 0 deletions samples/http-json-cloudevents/json_sample_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest
from json_sample_server import app

from cloudevents.http import CloudEvent, to_binary_http, to_structured_http


@pytest.fixture
def client():
app.testing = True
return app.test_client()


def test_binary_request(client):
# This data defines a binary cloudevent
attributes = {
"type": "com.example.sampletype1",
"source": "https://example.com/event-producer",
}
data = {"message": "Hello World!"}

event = CloudEvent(attributes, data)
headers, body = to_binary_http(event)

r = client.post("/", headers=headers, data=body)
assert r.status_code == 204


def test_structured_request(client):
# This data defines a binary cloudevent
attributes = {
"type": "com.example.sampletype2",
"source": "https://example.com/event-producer",
}
data = {"message": "Hello World!"}

event = CloudEvent(attributes, data)
headers, body = to_structured_http(event)

r = client.post("/", headers=headers, data=body)
assert r.status_code == 204
Empty file.
76 changes: 0 additions & 76 deletions samples/python-requests/cloudevent_to_request.py

This file was deleted.

38 changes: 0 additions & 38 deletions samples/python-requests/request_to_cloudevent.py

This file was deleted.