Skip to content

Commit

Permalink
Merge pull request #6 from JonatanMartens/development
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
JonatanMartens authored Aug 23, 2020
2 parents a590c6e + dfbb202 commit a40f58a
Show file tree
Hide file tree
Showing 30 changed files with 81 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-python-package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish zeebepy
name: Publish pyzeebe

on:
release:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test-python-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Test zeebepy
name: Test pyzeebe

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ coverage = "~=5.2.1"
pytest = "~=6.0.1"
pytest-grpc = "~=0.8.0"
mypy = "~=0.782"
zeebepy = {editable = true, path = "."}
coveralls = "~=2.1.2"
importlib-metadata = "~=1.7.0"
pyzeebe = {editable = true, path = "."}

[packages]
grpcio = "~=1.31.0"
Expand Down
10 changes: 5 additions & 5 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[![Coverage Status](https://coveralls.io/repos/github/JonatanMartens/zeebepy/badge.svg?branch=master)](https://coveralls.io/github/JonatanMartens/zeebepy?branch=master)
![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/JonatanMartens/zeebepy/Test%20zeebepy/master)
![GitHub issues](https://img.shields.io/github/issues-raw/JonatanMartens/zeebepy)
![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/JonatanMartens/zeebepy)
![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed-raw/JonatanMartens/zeebepy)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/JonatanMartens/zeebepy)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/zeebepy)
![PyPI](https://img.shields.io/pypi/v/zeebepy)
[![Coverage Status](https://coveralls.io/repos/github/JonatanMartens/pyzeebe/badge.svg?branch=master)](https://coveralls.io/github/JonatanMartens/pyzeebe?branch=master)
![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/JonatanMartens/pyzeebe/Test%20pyzeebe/master)
![GitHub issues](https://img.shields.io/github/issues-raw/JonatanMartens/pyzeebe)
![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/JonatanMartens/pyzeebe)
![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed-raw/JonatanMartens/pyzeebe)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/JonatanMartens/pyzeebe)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyzeebe)
![PyPI](https://img.shields.io/pypi/v/pyzeebe)



# Zeebepy
Zeebepy is a python grpc client for Zeebe.
# Pyzeebe
pyzeebe is a python grpc client for Zeebe.

Zeebe version support:

| Zeebepy version | Tested Zeebe versions |
| Pyzeebe version | Tested Zeebe versions |
|:---------------:|----------------|
| 1.0.1 | 0.24.2 |

## Getting Started
To install:

`pip install zeebepy`
`pip install pyzeebe`

## Usage

### Worker

```python
from zeebepy import ZeebeWorker, Task, TaskStatusController, TaskContext
from pyzeebe import ZeebeWorker, Task, TaskStatusController, TaskContext

def example_task(input: str):
return {'output': f'Hello world, {input}!'}
Expand All @@ -49,7 +49,7 @@ worker.work() # Now every time that a task with type example is called example_t
```

## Tests
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install zeebepy
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install pyzeebe

`pytest .`

Expand Down
2 changes: 1 addition & 1 deletion examples/worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict

from zeebepy import Task, TaskContext, TaskStatusController, ZeebeWorker
from pyzeebe import Task, TaskContext, TaskStatusController, ZeebeWorker


def example_task(input: str) -> Dict:
Expand Down
4 changes: 4 additions & 0 deletions pyzeebe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pyzeebe.task.task import Task
from pyzeebe.task.task_context import TaskContext
from pyzeebe.task.task_status_controller import TaskStatusController
from pyzeebe.worker.worker import ZeebeWorker
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from random import randint
from uuid import uuid4

from zeebepy.task.task import Task
from zeebepy.task.task_context import TaskContext
from pyzeebe.task.task import Task
from pyzeebe.task.task_context import TaskContext

RANDOM_RANGE = 100000

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from zeebepy.task.task_decorator import TaskDecorator
from pyzeebe.task.task_decorator import TaskDecorator


class ZeebeDecoratorBase(object):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from zeebepy.common.random_utils import random_task_context
from zeebepy.decorators.zeebe_decorator_base import ZeebeDecoratorBase
from pyzeebe.common.random_utils import random_task_context
from pyzeebe.decorators.zeebe_decorator_base import ZeebeDecoratorBase


def test_add_before():
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import grpc

from zeebepy.grpc_internals.zeebe_pb2 import *
from zeebepy.grpc_internals.zeebe_pb2_grpc import GatewayStub
from zeebepy.task.task_context import TaskContext
from pyzeebe.grpc_internals.zeebe_pb2 import *
from pyzeebe.grpc_internals.zeebe_pb2_grpc import GatewayStub
from pyzeebe.task.task_context import TaskContext


class ZeebeAdapter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import grpc
import pytest

from zeebepy.common.random_utils import RANDOM_RANGE
from zeebepy.grpc_internals.zeebe_adapter import ZeebeAdapter
from zeebepy.grpc_internals.zeebe_pb2 import *
from zeebepy.grpc_internals.zeebe_pb2_grpc import GatewayServicer
from pyzeebe.common.random_utils import RANDOM_RANGE
from pyzeebe.grpc_internals.zeebe_adapter import ZeebeAdapter
from pyzeebe.grpc_internals.zeebe_pb2 import *
from pyzeebe.grpc_internals.zeebe_pb2_grpc import GatewayServicer

zeebe_adapter: ZeebeAdapter

Expand Down Expand Up @@ -62,7 +62,7 @@ def PublishMessage(self, request, context):

@pytest.fixture(scope='module')
def grpc_add_to_server():
from zeebepy.grpc_internals.zeebe_pb2_grpc import add_GatewayServicer_to_server
from pyzeebe.grpc_internals.zeebe_pb2_grpc import add_GatewayServicer_to_server
return add_GatewayServicer_to_server


Expand All @@ -73,7 +73,7 @@ def grpc_servicer():

@pytest.fixture(scope='module')
def grpc_stub_cls(grpc_channel):
from zeebepy.grpc_internals.zeebe_pb2_grpc import GatewayStub
from pyzeebe.grpc_internals.zeebe_pb2_grpc import GatewayStub
return GatewayStub


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

import zeebepy.grpc_internals.zeebe_pb2 as zeebe__pb2
import pyzeebe.grpc_internals.zeebe_pb2 as zeebe__pb2


class GatewayStub(object):
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions zeebepy/task/task.py → pyzeebe/task/task.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Callable, List, Dict

from zeebepy.decorators.zeebe_decorator_base import ZeebeDecoratorBase
from zeebepy.task.task_context import TaskContext
from zeebepy.task.task_status_controller import TaskStatusController
from pyzeebe.decorators.zeebe_decorator_base import ZeebeDecoratorBase
from pyzeebe.task.task_context import TaskContext
from pyzeebe.task.task_status_controller import TaskStatusController


# TODO: Add support for async tasks
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Callable

from zeebepy.task.task_context import TaskContext
from pyzeebe.task.task_context import TaskContext

TaskDecorator = Callable[[TaskContext], TaskContext]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from zeebepy.grpc_internals.zeebe_adapter import ZeebeAdapter
from zeebepy.task.task_context import TaskContext
from pyzeebe.grpc_internals.zeebe_adapter import ZeebeAdapter
from pyzeebe.task.task_context import TaskContext


class TaskStatusController:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import pytest

from zeebepy.common.random_utils import random_task_context
from zeebepy.grpc_internals.zeebe_adapter import ZeebeAdapter
from zeebepy.task.task_status_controller import TaskStatusController
from pyzeebe.common.random_utils import random_task_context
from pyzeebe.grpc_internals.zeebe_adapter import ZeebeAdapter
from pyzeebe.task.task_status_controller import TaskStatusController

task_status_controller: TaskStatusController

Expand All @@ -20,22 +20,22 @@ def run_around_tests():


def test_success():
with patch('zeebepy.grpc_internals.zeebe_adapter.ZeebeAdapter.complete_job') as complete_job_mock:
with patch('pyzeebe.grpc_internals.zeebe_adapter.ZeebeAdapter.complete_job') as complete_job_mock:
task_status_controller.success()
complete_job_mock.assert_called_with(job_key=task_status_controller.context.key,
variables=task_status_controller.context.variables)


def test_error():
with patch('zeebepy.grpc_internals.zeebe_adapter.ZeebeAdapter.throw_error') as throw_error_mock:
with patch('pyzeebe.grpc_internals.zeebe_adapter.ZeebeAdapter.throw_error') as throw_error_mock:
message = str(uuid4())
task_status_controller.error(message)
throw_error_mock.assert_called_with(job_key=task_status_controller.context.key,
message=message)


def test_failure():
with patch('zeebepy.grpc_internals.zeebe_adapter.ZeebeAdapter.fail_job') as fail_job_mock:
with patch('pyzeebe.grpc_internals.zeebe_adapter.ZeebeAdapter.fail_job') as fail_job_mock:
message = str(uuid4())
task_status_controller.failure(message)
fail_job_mock.assert_called_with(job_key=task_status_controller.context.key,
Expand Down
2 changes: 1 addition & 1 deletion zeebepy/task/task_test.py → pyzeebe/task/task_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uuid

from zeebepy.task.task import Task
from pyzeebe.task.task import Task


def test_add_before():
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions zeebepy/worker/worker.py → pyzeebe/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from concurrent.futures import ThreadPoolExecutor
from typing import List, Callable, Generator, Dict, Tuple

from zeebepy.common.exceptions import TaskNotFoundException, NotEnoughTasksException
from zeebepy.decorators.zeebe_decorator_base import ZeebeDecoratorBase
from zeebepy.grpc_internals.zeebe_adapter import ZeebeAdapter
from zeebepy.task.task import Task
from zeebepy.task.task_context import TaskContext
from zeebepy.task.task_decorator import TaskDecorator
from zeebepy.task.task_status_controller import TaskStatusController
from pyzeebe.common.exceptions import TaskNotFoundException, NotEnoughTasksException
from pyzeebe.decorators.zeebe_decorator_base import ZeebeDecoratorBase
from pyzeebe.grpc_internals.zeebe_adapter import ZeebeAdapter
from pyzeebe.task.task import Task
from pyzeebe.task.task_context import TaskContext
from pyzeebe.task.task_decorator import TaskDecorator
from pyzeebe.task.task_status_controller import TaskStatusController


# TODO: Add support for async tasks
Expand Down
Loading

0 comments on commit a40f58a

Please sign in to comment.