Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/110-inspector-helper-classes' in…
Browse files Browse the repository at this point in the history
…to 110-inspector-helper-classes

# Conflicts:
#	tests/cassettes/TestProperties.test_create_and_delete_property.json
#	tests/cassettes/TestSelectListProperty.test_set_options_list.json
#	tests/test_properties.py
  • Loading branch information
raduiordache committed Jun 22, 2017
2 parents fbe5b4c + e1ba5b7 commit 33e5ee4
Show file tree
Hide file tree
Showing 64 changed files with 1,123 additions and 761 deletions.
43 changes: 42 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,47 @@ Change Log

pykechain changelog

1.9.0 (UNRELEASED)
------------------

* Improved test coverage and refactored the HTTP codes to human readable form
* Add `Part.as_dict()` method to retrieve the properties of a part in pykechain as a python dictionary as `{<property_name> : <property_value>}`
* Added the ability to optionally update the name of a part together with the value of its properties. See the `Part.update()` method.

1.8.0 (05JUN17)
---------------
* Added `Part.instances()` method for models to find their associated instances. (#113) Also added a `Part.instance()` method if you for sure that you will get only a single instance back.
* Added `Activity.subprocess()`, `Activity.siblings()` and `Activity.children()` methods to the `Activity`. It eases relative retrieval of other tasks in the task tree. Documentation is included. (#100)
* added `Activity.activity_type` property to the Activity.
* added `ActivityType` enumeration. This can be used to check if the `activity_type` of an `Activity` is either a Usertask or a Subprocess.
* Added ability to retrieve an `Activity` based on an id. As this included in the low level `Client` object, it can be used almost everywhere to retrieve an activity by its id (or primary key, pk) eg. in the `Scope.activity`.
* Added ability to add additional keywords to the activities searcher to be able to search by name, pk, container etc.
* Added a FutureDeprecationWarning to the `Activity.create_activity()` method. This will is replace with the `Activity.create()` method. Update your code please!
* Added a convenience method to retrieve models and instances related to a task at once: `Activity.associated_parts()`. Making use of the already provided method in `Activity.parts()`. (#118)
* Added missing tests for `Activity.parts()` and `Activity.associated_parts()`
* added tests for all new features.
* Updated the documentation.


1.7.3 (01JUN17)
---------------
* Updated documentation for activity startdate and duedate editting using timezone supported datetime objects.
If a user want to make use of timezone aware datetime the best way to do it is::

>>> my_tz = pytz.timezone('Europe/Amsterdam')
>>> start_date = my_tz.localize(datetime(2017,6,1,23,59,0))
>>> due_date = my_tz.localize(datetime(2017,12,31))
>>> my_task.edit(start_date = start_date, due_date = due_date)

* Fixed a bug where a naive due_date and no provided start_date resulted in an error. Keep them bugs comin'!


1.7.2 (01JUN17)
---------------
* updated `property.part` property that gets the part for its property. For model this did not work as underlying
only `category=INSTANCES` were retrieved. Thanks to @joost.schut for finding it and reporting.
* updated requirements for development.


1.7.1 (29MAY17)
---------------
Expand All @@ -12,7 +53,7 @@ pykechain changelog


1.7.0 (29MAY17)
------------------
---------------
* Added `ReferencyProperty.choices()` convenience method to provide you the list of parts (instances) that are
acceptable as a choice for the value of the reference property.
* Added `Part.proxy_model()` method that will return the model that is used as the basis for the proxied model.
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
KE-chain Python SDK
===================

.. image:: https://img.shields.io/pypi/v/pykechain.svg
.. image:: https://img.shields.io/pypi/v/pykechain.svg?style=flat-square
:target: https://pypi.python.org/pypi/pykechain
:alt: Version

.. image:: https://img.shields.io/pypi/pyversions/pykechain.svg
.. image:: https://img.shields.io/pypi/pyversions/pykechain.svg?style=flat-square
:target: https://pypi.python.org/pypi/pykechain
:alt: Supported Python Versions

.. image:: https://travis-ci.org/KE-works/pykechain.svg?branch=master
.. image:: https://travis-ci.org/KE-works/pykechain.svg?branch=master&style=flat-square
:target: https://travis-ci.org/KE-works/pykechain
:alt: Build Status

.. image:: https://readthedocs.org/projects/pykechain/badge/?version=latest
.. image:: https://readthedocs.org/projects/pykechain/badge/?version=latest&style=flat-square
:target: http://pykechain.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://coveralls.io/repos/github/KE-works/pykechain/badge.svg?branch=master
.. image:: https://coveralls.io/repos/github/KE-works/pykechain/badge.svg?branch=master&style=flat-square
:target: https://coveralls.io/github/KE-works/pykechain?branch=master
:alt: Coverage Status

.. image:: https://pyup.io/repos/github/KE-works/pykechain/shield.svg
.. image:: https://pyup.io/repos/github/KE-works/pykechain/shield.svg?style=flat-square
:target: https://pyup.io/repos/github/KE-works/pykechain/
:alt: Updates

Expand Down
2 changes: 1 addition & 1 deletion pykechain/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = 'pykechain'
description = 'KE-chain Python SDK'

version = '1.7.1'
version = '1.8.0'

author = 'KE-works BV'
email = 'support+pykechain@ke-works.com'
38 changes: 22 additions & 16 deletions pykechain/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, url='http://localhost:8000/', check_certificates=True):
if not check_certificates:
self.session.verify = False

def __repr__(self):
def __repr__(self): # pragma: no cover
return "<pyke Client '{}'>".format(self.api_root)

@classmethod
Expand Down Expand Up @@ -126,7 +126,7 @@ def login(self, username=None, password=None, token=None):
>>> client = Client()
>>> client.login('username','password')
"""
if token:
self.headers['Authorization'] = 'Token {}'.format(token)
Expand Down Expand Up @@ -206,22 +206,28 @@ def scope(self, *args, **kwargs):

return _scopes[0]

def activities(self, name=None, scope=None):
# type: (Optional[str], Optional[str]) -> List[Activity]
def activities(self, name=None, pk=None, scope=None, **kwargs):
# type: (Optional[str], Optional[str], Optional[str], **Any) -> List[Activity]
"""Search on activities with optional name filter.
:param pk: id (primary key) of the activity to retrieve
:param name: filter the activities by name
:param scope: filter by scope id
:return: :obj:`list` of :obj:`Activity`
:raises: NotFoundError
"""
r = self._request('GET', self._build_url('activities'), params={
request_params = {
'id': pk,
'name': name,
'scope': scope
})
}
if kwargs:
request_params.update(**kwargs)

r = self._request('GET', self._build_url('activities'), params=request_params)

if r.status_code != requests.codes.ok: # pragma: no cover
raise NotFoundError("Could not retrieve activities")
raise NotFoundError("Could not retrieve activities. Server responded with {}".format(str(r)))

data = r.json()

Expand Down Expand Up @@ -275,22 +281,22 @@ def parts(self,
Examples
--------
Return all parts (defaults to instances) with exact name 'Gears'.
>>> client = Client(url='https://default.localhost:9443', verify=False)
>>> client.login('admin','pass')
>>> client.parts(name='Gears') # doctest:Ellipsis
...
Return all parts with category is MODEL or category is INSTANCE.
>>> client.parts(name='Gears', category=None) # doctest:Ellipsis
...
Return a maximum of 5 parts
>>> client.parts(limit=5) # doctest:Ellipsis
...
"""
# if limit is provided and the batchsize is bigger than the limit, ensure that the batch size is maximised
if limit and limit < batch:
Expand Down Expand Up @@ -406,7 +412,7 @@ def create_activity(self, process, name, activity_class="UserTask"):

r = self._request('POST', self._build_url('activities'), data=data)

if r.status_code != 201:
if r.status_code != requests.codes.created: # pragma: no cover
raise APIError("Could not create activity")

data = r.json()
Expand All @@ -418,7 +424,7 @@ def _create_part(self, action, data):
params={"select_action": action},
data=data)

if r.status_code != requests.codes.created:
if r.status_code != requests.codes.created: # pragma: no cover
raise APIError("Could not create part, {}: {}".format(str(r), r.content))

return Part(r.json()['results'][0], client=self)
Expand Down Expand Up @@ -470,8 +476,8 @@ def create_proxy_model(self, model, parent, name, multiplicity='ZERO_MANY'):
whole subassembly to the 'parent' model.
:param name: Name of the new proxy model
:param parent: parent of the
:param multiplicity: the multiplicity of the new proxy model (default ONE_MANY)
:param parent: parent of the
:param multiplicity: the multiplicity of the new proxy model (default ONE_MANY)
:return: the new proxy model part
"""
assert model.category == Category.MODEL, "The model should be of category MODEL"
Expand Down Expand Up @@ -510,7 +516,7 @@ def create_property(self, model, name, description, property_type='CHAR', defaul
r = self._request('POST', self._build_url('properties'),
data=data)

if r.status_code != 201:
if r.status_code != requests.codes.created:
raise APIError("Could not create property")

prop = Property.create(r.json()['results'][0], client=self)
Expand Down
18 changes: 18 additions & 0 deletions pykechain/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,21 @@ class PropertyType(Enum):
BOOLEAN_VALUE = "BOOLEAN_VALUE"
CHAR_VALUE = "CHAR_VALUE"
ATTACHMENT_VALUE = "ATTACHMENT_VALUE"


class ActivityType(Enum):
"""The various Acitivity types that are accepted by KE-chain."""

USERTASK = "UserTask"
SERVICETASK = "ServiceTask" # RND code only
SUBPROCESS = "Subprocess"


class ComponentXType(Enum):
"""The various inspectortypes supported in the customized task in KE-chain."""

PANEL = "panel"
PROPERTYGRID = "propertyGrid"
SUPERGRID = "superGrid"
PAGINATEDSUPERGRID = "paginatedSuperGrid"
FILTEREDGRID = "filteredGrid"
Loading

0 comments on commit 33e5ee4

Please sign in to comment.