Skip to content

Commit 1c32548

Browse files
Contributing
1 parent 6ada264 commit 1c32548

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python 3.11.3

CONTRIBUTING.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Contributing
2+
3+
## Getting Started
4+
5+
1. Install [asdf](https://asdf-vm.com)
6+
2. Install the asdf Python plugin
7+
8+
```bash
9+
asdf plugin add python https://github.com/danhper/asdf-python.git # Visit that repository to see installation prerequisites
10+
```
11+
12+
3. Run `asdf install` to install the version of Python specified in the [.tool-versions](.tool-versions) file
13+
4. Run `pip install -r requirements.txt` to install the Python dependencies
14+
15+
## Running the tests
16+
17+
```bash
18+
python -m pytest
19+
```
20+
21+
## Running the linter
22+
23+
```bash
24+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
25+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
26+
```

knockapi/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def request(self, method, endpoint, payload=None, options={}):
1818
url = '{}/v1{}'.format(self.host, endpoint)
1919

2020
extra_headers = {}
21-
if (method in ["post", "put"]) and options.get('idempotency_key') != None:
21+
if (method in ["post", "put"]) and options.get('idempotency_key') is not None:
2222
extra_headers['Idempotency-Key'] = options.get('idempotency_key')
2323

2424
r = requests.request(

knockapi/resources/messages.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from .service import Service
33

4+
45
class Messages(Service):
56
def list(self, options=None):
67
"""

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
requests
2+
flake8
3+
pytest

tests/test_workflows_class.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@
44

55
# Tests
66

7+
78
def test_trigger():
89
mocked_client = Mock()
910
workflows = Workflows(mocked_client)
10-
workflows.trigger("workflow-key", ["user-123"], {"foo": "bar"}, actor="actor-123", cancellation_key="cancel-key", tenant="tenant-123", options={"idempotency_key": "123"})
11+
workflows.trigger(
12+
"workflow-key",
13+
["user-123"],
14+
{"foo": "bar"},
15+
actor="actor-123",
16+
cancellation_key="cancel-key",
17+
tenant="tenant-123",
18+
options={"idempotency_key": "123"})
1119
mocked_client.request.assert_called_with("post", "/workflows/workflow-key/trigger", payload={
1220
"actor": "actor-123",
1321
"recipients": ["user-123"],
1422
"data": {"foo": "bar"},
1523
"cancellation_key": "cancel-key",
1624
"tenant": "tenant-123"},
1725
options={'idempotency_key': '123'})
18-

0 commit comments

Comments
 (0)