From 7224fd4b37d1a61136ecc921ed9d3e8ff6270054 Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Tue, 14 Jul 2015 02:37:25 +0300 Subject: [PATCH] Updating callable provider docs --- docs/images/callable.png | Bin 0 -> 15150 bytes docs/providers/callable.rst | 64 ++++++++++++++++----------------- examples/providers/callable.py | 55 +++++++++++++--------------- 3 files changed, 54 insertions(+), 65 deletions(-) create mode 100644 docs/images/callable.png diff --git a/docs/images/callable.png b/docs/images/callable.png new file mode 100644 index 0000000000000000000000000000000000000000..67a7e492f5321770e88ac57027ec61beafe9397a GIT binary patch literal 15150 zcmdtJWmKDAw=bFs1xm3}JQOQV(E`B>#ob*>vEo5fAXt%>;_gsfi&I=0N^o~gLvVMO zoBrSZ?(^Z?ea9VpoUuQgjFFLN$$ZvYbFDS!{LMKNs-_}~`;_7-006+1my^-}03L$? zfCmFukI*%kryIoRpU2h`$`SxTRTR#R83wxiz*R$55>P$_+(Z{>%;hwc0RS&X0Kh*8 z0JuU|`ELLK?py%C)_VXzC>a1C1*bQui=gR1YD!wt_xJY*1R@|H0Ns;=gM*Zo#V9Dp zCAY^ewI#55_4@kSzXAEFbWG7M2&DGGr+Qw?Gyb)N>N7%Oi>OLT6IVKJQ8qEft&>Z- zuN}oBYu7ioZne|TpiKgC@QL-KkhX>Q#bYOzH-GldlDm=cKl{JO=AOvd03JNV_icWF zPs$n&qX}vEs+?AHjqt9R{+Lj29Fli(a^mRd`1|*7DJiL~tu1|h{kXU|GBUFK{QSDQ zy0Njb58-7FY3(!=G=5h8>Asn9kc66;y2{9E_o5;2_uscSx8uzdks7fl`=^_WnF0j`8XdrJG z>J&EKKd$gf>EVNi1Xu)YqDmAD93LXe*x#x+rgz|zP!d&t8$h${!3RZIDZp0@Dmiok z8!V^q3ILF${rx_WcMpsQ06;79QW9F9=5{ke{TB3G5Yi;hgy+Qj<#lc5Op#Qwqzpr^ zCgc=6rk4)G9U??gp?qmU1ZbT3Yu)jl0PMvwGA z@OjC`R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QUu|g6YudH5Ew94Gz3S_Bd2n?r82OY6puJm5k-22g@=m zC8wICq|M~jjSdp!(8txHC|ffXUs4DTFx z&zD0F9z)+2AtrEGIG*2?BBsWU&b?7~x7@otWp6qMX^x7MZ1EG=;HtDhwkK`Pj7YiD zafnfcLJ?lR219Gte1s`py<)VdYI~|pc$Rvs0!d~{Hj|I84Zq2H+#?a<+oouZ_4fRD zt9)AOQuqaNmzT0~Jdx%RPtlZRKZB+P4=hpP)yzyFxQz5-FE$9J^Wk=;oaw`++Am17 z61gd6yn&Hm-dcM(x9=#3t0p`9El@p#pS)c0z)$}(} zJ{gxumMKBss;$r&0)KgY{s)~^-d0S%hQ~i>jG%vJ9*2~1bwydDe9=(=bRvfsJ}WS0 z`pB<2KlE2QN5r{q=gQ&P`vG=Z_JMV!Pd-iCc&g526DIJAH{W>8SP1R2eJy#OLt!wwEl~vdfI&160 z`w2i~bOt~nv!;@!&!_&QqF(|EY5ZG3(vI$d&Zp`81%+h)tsqm?XFga&d;1^$7db@# z2dnX6_n2oNH4_mIz%KM_8Qi4x+$_x8EQQQnEYUvz9xiUa*IWXxxp}pCc!julgt)oc rxVVJ4xYpS@|NiUre-Su1S=d;4{?`PF&Pk$wCoV6oB2_N={`3C>SGxkn literal 0 HcmV?d00001 diff --git a/docs/providers/callable.rst b/docs/providers/callable.rst index 9968818c..9d1b4b35 100644 --- a/docs/providers/callable.rst +++ b/docs/providers/callable.rst @@ -1,64 +1,60 @@ Callable providers ------------------ -``Callable`` provider is a provider that decorates particular callable with +``Callable`` provider is a provider that wraps particular callable with some injections. Every call of this provider returns result of call of initial callable. ``Callable`` provider uses ``KwArg`` injections. ``KwArg`` injections are -done by passing injectable values like keyword arguments during call time. +done by passing injectable values as keyword arguments during call time. Context keyword arguments have higher priority than ``KwArg`` injections. Example: +.. image:: /images/callable.png + :width: 100% + :align: center + .. code-block:: python """`Callable` providers examples.""" from objects.providers import Callable - from objects.providers import Singleton - from objects.injections import KwArg - class UserService(object): + class SomeCrypt(object): - """Example class UserService.""" + """Example class SomeCrypt.""" - def get_by_id(self, id): - """Return user info by user id.""" - return {'id': id, 'login': 'example_user'} + @staticmethod + def encrypt(data, password): + """Encypt data using password.""" + return ''.join((password, data, password)) + + @staticmethod + def decrypt(data, password): + """Decrypt data using password.""" + return data[len(password):-len(password)] - def get_user_by_id(user_id, users_service): - """Example function that has input arg and dependency on database.""" - return users_service.get_by_id(user_id) - - - # UserService and get_user_by_id providers: - users_service = Singleton(UserService) - get_user_by_id = Callable(get_user_by_id, - KwArg('users_service', users_service)) + # Encrypt and decrypt function providers: + encrypt = Callable(SomeCrypt.encrypt, + KwArg('password', 'secret123')) + decrypt = Callable(SomeCrypt.decrypt, + KwArg('password', 'secret123')) # Making some asserts: - assert get_user_by_id(1) == {'id': 1, 'login': 'example_user'} - assert get_user_by_id(2) == {'id': 2, 'login': 'example_user'} + initial_data = 'some_data' + encrypted1 = encrypt(initial_data) + decrypted1 = decrypt(encrypted1) + + assert decrypted1 == initial_data # Context keyword arguments priority example: - class UserServiceMock(object): - - """Example class UserService.""" - - def get_by_id(self, id): - """Return user info by user id.""" - return {'id': id, 'login': 'mock'} - - - user_service_mock = UserServiceMock() - - user3 = get_user_by_id(1, users_service=user_service_mock) - - assert user3 == {'id': 1, 'login': 'mock'} + encrypted2 = encrypt(initial_data, password='another_secret') + decrypted2 = decrypt(encrypted2) + assert decrypted2 != initial_data diff --git a/examples/providers/callable.py b/examples/providers/callable.py index b3112569..73654eb4 100644 --- a/examples/providers/callable.py +++ b/examples/providers/callable.py @@ -1,47 +1,40 @@ """`Callable` providers examples.""" from objects.providers import Callable -from objects.providers import Singleton - from objects.injections import KwArg -class UserService(object): +class SomeCrypt(object): - """Example class UserService.""" + """Example class SomeCrypt.""" - def get_by_id(self, id): - """Return user info by user id.""" - return {'id': id, 'login': 'example_user'} + @staticmethod + def encrypt(data, password): + """Encypt data using password.""" + return ''.join((password, data, password)) + + @staticmethod + def decrypt(data, password): + """Decrypt data using password.""" + return data[len(password):-len(password)] -def get_user_by_id(user_id, users_service): - """Example function that has input arg and dependency on database.""" - return users_service.get_by_id(user_id) - - -# UserService and get_user_by_id providers: -users_service = Singleton(UserService) -get_user_by_id = Callable(get_user_by_id, - KwArg('users_service', users_service)) +# Encrypt and decrypt function providers: +encrypt = Callable(SomeCrypt.encrypt, + KwArg('password', 'secret123')) +decrypt = Callable(SomeCrypt.decrypt, + KwArg('password', 'secret123')) # Making some asserts: -assert get_user_by_id(1) == {'id': 1, 'login': 'example_user'} -assert get_user_by_id(2) == {'id': 2, 'login': 'example_user'} +initial_data = 'some_data' +encrypted1 = encrypt(initial_data) +decrypted1 = decrypt(encrypted1) + +assert decrypted1 == initial_data # Context keyword arguments priority example: -class UserServiceMock(object): +encrypted2 = encrypt(initial_data, password='another_secret') +decrypted2 = decrypt(encrypted2) - """Example class UserService.""" - - def get_by_id(self, id): - """Return user info by user id.""" - return {'id': id, 'login': 'mock'} - - -user_service_mock = UserServiceMock() - -user3 = get_user_by_id(1, users_service=user_service_mock) - -assert user3 == {'id': 1, 'login': 'mock'} +assert decrypted2 != initial_data