Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.1.3'
Browse files Browse the repository at this point in the history
* release/v0.1.3:
  Bump version: 0.1.2 → 0.1.3
  Updated request hooks to be accessed with  attribute instead of  attribute in Hooks.
  • Loading branch information
m-housh committed Oct 24, 2016
2 parents 24133f8 + abf1459 commit ad96ac9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion eve_resource/__init__.py
Expand Up @@ -9,7 +9,7 @@

__author__ = 'Michael Housh'
__email__ = 'mhoush@houshhomeenergy.com'
__version__ = '0.1.2'
__version__ = '0.1.3'

__all__ = [
# exceptions
Expand Down
12 changes: 6 additions & 6 deletions eve_resource/hooks.py
Expand Up @@ -140,7 +140,7 @@ class Hooks(object):
def __init__(self, resource: str) -> None:
self.resource = resource
self._mongo = None
self._requests = None
self._request = None

@property
def mongo(self) -> EventHooks:
Expand All @@ -153,14 +153,14 @@ def mongo(self) -> EventHooks:
return self._mongo

@property
def requests(self) -> EventHooks:
def request(self) -> EventHooks:
"""A :class:`EventHooks` setup for request type events that can
be registered with an :class:`eve.Eve` api.
"""
if self._requests is None:
self._requests = request_hooks(self.resource)
return self._requests
if self._request is None:
self._request = request_hooks(self.resource)
return self._request

def init_api(self, api: Eve) -> None:
"""Register's the hooks with an :class:`eve.Eve` instance.
Expand All @@ -175,4 +175,4 @@ def init_api(self, api: Eve) -> None:
raise TypeError(api)

self.mongo.init_api(api)
self.requests.init_api(api)
self.request.init_api(api)
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.2
current_version = 0.1.3
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -26,7 +26,7 @@

setup(
name='eve_resource',
version='0.1.2',
version='0.1.3',
description="Resource utilities for Eve",
long_description=readme + '\n\n' + history,
author="Michael Housh",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_hooks.py
Expand Up @@ -99,11 +99,11 @@ def test_Hooks(test_func):
_hooks = hooks.Hooks('resource')
assert isinstance(_hooks.mongo, hooks.EventHooks)
assert len(_hooks.mongo.events) == 0
assert isinstance(_hooks.requests, hooks.EventHooks)
assert len(_hooks.requests.events) == 0
assert isinstance(_hooks.request, hooks.EventHooks)
assert len(_hooks.request.events) == 0

_hooks.mongo.event('insert', test_func)
_hooks.requests.event('post_PATCH', test_func)
_hooks.request.event('post_PATCH', test_func)

api = Eve(settings={'DOMAIN': {}})
assert len(api.on_insert) == 0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resource.py
Expand Up @@ -120,7 +120,7 @@ def test(items):
accounts.init_api(app)
assert len(app.on_insert) == 1

@accounts.hooks.requests('pre_GET', 'post_POST')
@accounts.hooks.request('pre_GET', 'post_POST')
def tes2(*args, **kwargs):
pass

Expand Down

0 comments on commit ad96ac9

Please sign in to comment.