ó
O'—^c           @  sÄ   d  d l  m Z d  d l Z d  d l m Z d  d l m Z d  d l m Z d d l	 m
 Z
 d d l m Z e
 ƒ  Z e ƒ  Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   unicode_literalsN(   t   reverse(   t   TestCase(   t   override_settingsi   (   t   get_application_model(   t   get_user_modelt   BaseTestc           B  s   e  Z d  „  Z d „  Z RS(   c         C  s:   t  j j d d d ƒ |  _ t  j j d d d ƒ |  _ d  S(   Nu   foo_useru   test@user.comu   123456u   bar_useru   dev@user.com(   t	   UserModelt   objectst   create_usert   foo_usert   bar_user(   t   self(    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt   setUp   s    c         C  s   |  j  j ƒ  |  j j ƒ  d  S(   N(   R
   t   deleteR   (   R   (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt   tearDown   s    (   t   __name__t
   __module__R   R   (    (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyR      s   	t   TestApplicationRegistrationViewc           B  s   e  Z d  „  Z d „  Z RS(   c         C  sk   d d l  m } d d l m } d d l m } d | _ | ƒ  j ƒ  } |  j | | j	 j
 ƒ d | _ d S(	   uÄ   
        Tests that the form class returned by the 'get_form_class' method is
        bound to custom application model defined in the
        'OAUTH2_PROVIDER_APPLICATION_MODEL' setting.
        i   (   t   ApplicationRegistrationi   (   t   TestApplication(   t   oauth2_settingsu   tests.TestApplicationu   oauth2_provider.ApplicationN(   t   views.applicationR   t   modelsR   t   settingsR   t   APPLICATION_MODELt   get_form_classt   assertEqualt   _metat   model(   R   R   R   R   t   application_form_class(    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt   test_get_form_class   s    	c         C  s¬   |  j  j d d d d ƒ i d d 6d d 6d d 6t j d	 6d
 d 6t j d 6} |  j  j t d ƒ | ƒ } |  j | j d ƒ t j	 j
 d d ƒ } |  j | j j d ƒ d  S(   Nt   usernameu   foo_usert   passwordu   123456u   Foo appu   nameu	   client_idu   client_secretu   client_typeu   http://example.comu   redirect_urisu   authorization_grant_typeu   oauth2_provider:registeri.  t   name(   t   clientt   logint   Applicationt   CLIENT_CONFIDENTIALt   GRANT_AUTHORIZATION_CODEt   postR   R   t   status_codeR   t   gett   userR    (   R   t	   form_datat   responset   app(    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt"   test_application_registration_user,   s    
(   R   R   R   R/   (    (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyR      s   	t   TestApplicationViewsc           B  s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C  s7   t  j j d | d d d t  j d t  j d | ƒ } | S(   NR"   t   redirect_urisu   http://example.comt   client_typet   authorization_grant_typeR+   (   R%   R   t   createR&   R'   (   R   R"   R+   R.   (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt   _create_application@   s
    	c         C  s   t  t |  ƒ j ƒ  |  j d |  j ƒ |  _ |  j d |  j ƒ |  _ |  j d |  j ƒ |  _ |  j d |  j ƒ |  _	 |  j d |  j ƒ |  _
 d  S(   Nu   app foo_user 1u   app foo_user 2u   app foo_user 3u   app bar_user 1u   app bar_user 2(   t   superR0   R   R5   R
   t	   app_foo_1t	   app_foo_2t	   app_foo_3R   t	   app_bar_1t	   app_bar_2(   R   (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyR   G   s    c         C  s*   t  t |  ƒ j ƒ  t j j ƒ  j ƒ  d  S(   N(   R6   R0   R   R%   R   t   allR   (   R   (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyR   P   s    c         C  se   |  j  j d d d d ƒ |  j  j t d ƒ ƒ } |  j | j d ƒ |  j t | j d ƒ d ƒ d  S(	   NR    u   foo_userR!   u   123456u   oauth2_provider:listiÈ   u   object_listi   (   R#   R$   R*   R   R   R)   t   lent   context(   R   R-   (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt   test_application_listT   s    c         C  sW   |  j  j d d d d ƒ |  j  j t d d |  j j f ƒƒ } |  j | j d ƒ d  S(   NR    u   foo_userR!   u   123456u   oauth2_provider:detailt   argsiÈ   (   R#   R$   R*   R   R7   t   pkR   R)   (   R   R-   (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt   test_application_detail_owner[   s    'c         C  sW   |  j  j d d d d ƒ |  j  j t d d |  j j f ƒƒ } |  j | j d ƒ d  S(   NR    u   foo_userR!   u   123456u   oauth2_provider:detailR@   i”  (   R#   R$   R*   R   R:   RA   R   R)   (   R   R-   (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt!   test_application_detail_not_ownera   s    '(   R   R   R5   R   R   R?   RB   RC   (    (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyR0   ?   s   						(   t
   __future__R    t   mockt   django.core.urlresolversR   t   django.testR   t   django.test.utilsR   R   R   t   compatR   R%   R   R   R   R0   (    (    (    sN   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_application_views.pyt   <module>   s   		
&