ó
O'—^c           @  sþ   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d l	 m
 Z
 d  d l m Z d d l m Z m Z m Z d d	 l m Z d d
 l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   unicode_literals(   t   ImproperlyConfigured(   t   View(   t   TestCaset   RequestFactory(   t   HttpResponse(   t   Serveri   (   t   OAuthLibMixint   ScopedResourceMixint   ProtectedResourceMixin(   t   OAuthLibCore(   t   OAuth2Validatort   BaseTestc           B  s   e  Z e d  „  ƒ Z RS(   c         C  s#   t  ƒ  |  _ t t |  ƒ j ƒ  d  S(   N(   R   t   request_factoryt   superR   t
   setUpClass(   t   cls(    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR      s    (   t   __name__t
   __module__t   classmethodR   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR      s   t   TestOAuthLibMixinc           B  s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C  s9   d t  t f d „  ƒ  Y} | ƒ  } |  j t | j ƒ d  S(   Nt   TestViewc           B  s   e  Z e Z e Z RS(    (   R   R   R   t   server_classR   t   validator_class(    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR      s   (   R   R   t   assertRaisesR   t   get_oauthlib_backend_class(   t   selfR   t	   test_view(    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt#   test_missing_oauthlib_backend_class   s    	c         C  s9   d t  t f d „  ƒ  Y} | ƒ  } |  j t | j ƒ d  S(   NR   c           B  s   e  Z e Z e Z RS(    (   R   R   R   R   R
   t   oauthlib_backend_class(    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR   !   s   (   R   R   R   R   t
   get_server(   R   R   R   (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   test_missing_server_class    s    	c         C  s9   d t  t f d „  ƒ  Y} | ƒ  } |  j t | j ƒ d  S(   NR   c           B  s   e  Z e Z e Z RS(    (   R   R   R   R   R
   R   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR   *   s   (   R   R   R   R   R   (   R   R   R   (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   test_missing_validator_class)   s    	c         C  sW   d t  t f d „  ƒ  Y} |  j j d ƒ } d | _ | ƒ  } |  j | j ƒ  t ƒ d  S(   NR   c           B  s   e  Z e Z e Z e Z RS(    (   R   R   R   R   R   R   R
   R   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR   3   s   u	   /fake-requ   fake(   R   R   R   t   gett   usert   assertIsInstanceR   R   (   R   R   t   requestR   (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   test_correct_server2   s
    		c           ss   d t  f d „  ƒ  Y‰  d t t f ‡  f d †  ƒ  Y} |  j j d ƒ } d | _ | ƒ  } |  j | j ƒ  ˆ  ƒ d  S(   Nt   AnotherOauthLibBackendc           B  s   e  Z RS(    (   R   R   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR&   ?   s   R   c             s   e  Z e Z e Z ˆ  Z RS(    (   R   R   R   R   R   R   R   (    (   R&   (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR   B   s   u	   /fake-requ   fake(   t   objectR   R   R   R!   R"   t   assertEqualR   (   R   R   R$   R   (    (   R&   sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   test_custom_backend>   s    		(   R   R   R   R   R    R%   R)   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR      s
   							t   TestScopedResourceMixinc           B  s   e  Z d  „  Z d „  Z RS(   c         C  s9   d t  t f d „  ƒ  Y} | ƒ  } |  j t | j ƒ d  S(   NR   c           B  s   e  Z RS(    (   R   R   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR   Q   s   (   R   R   R   R   t
   get_scopes(   R   R   R   (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   test_missing_required_scopesP   s    	c         C  sB   d t  t f d „  ƒ  Y} | ƒ  } |  j | j ƒ  d d g ƒ d  S(   NR   c           B  s   e  Z d  d g Z RS(   u   scope1u   scope2(   R   R   t   required_scopes(    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR   Y   s   u   scope1u   scope2(   R   R   R(   R+   (   R   R   R   (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   test_correct_required_scopesX   s    	(   R   R   R,   R.   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR*   O   s   	t   TestProtectedResourceMixinc           B  s   e  Z d  „  Z RS(   c         C  sZ   d t  t f d „  ƒ  Y} |  j j d ƒ } | j ƒ  } | | ƒ } |  j | j d ƒ d  S(   NR   c           B  s   e  Z e Z e Z d  „  Z RS(   c         _  s   t  ƒ  S(   u3   Django 1.4 doesn't provide a default options method(   R   (   R   R$   t   argst   kwargs(    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   optionsg   s    (   R   R   R   R   R   R   R2   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR   c   s   u	   /fake-reqiÈ   (   R	   R   R   R2   t   as_viewR(   t   status_code(   R   R   R$   t   viewt   response(    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   test_options_shall_passb   s
    (   R   R   R7   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyR/   a   s   N(   t
   __future__R    t   django.core.exceptionsR   t   django.views.genericR   t   django.testR   R   t   django.httpR   t   oauthlib.oauth2R   t   views.mixinsR   R   R	   t   oauth2_backendsR
   t   oauth2_validatorsR   R   R   R*   R/   (    (    (    sC   /tmp/pip-unpacked-wheel-ndW12l/oauth2_provider/tests/test_mixins.pyt   <module>   s   9