ó
øĒTQc           @   sj  d  d l  m Z d  d l m Z d  d l m Z m Z m Z m Z d  d l	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z e
 e d e d	 d
  d e f d     Y  Z e
 e d e  d e f d     Y  Z e
 e d e  d e f d     Y  Z e
 e d e  d e f d     Y  Z e
 d e f d     Y Z d e f d     YZ d S(   iĸĸĸĸ(   t   settings(   t   get_user_model(   t   Groupt   Usert   SiteProfileNotAvailablet   UserManager(   t   skipIfCustomUser(   t   TestCase(   t   override_settings(   t   sixt   USE_TZt   AUTH_PROFILE_MODULEt    t   ProfileTestCasec           B   s   e  Z d    Z RS(   c         C   sĢ   t  j j d d  } t ` t j |  t d   | j   Wd  QXd t _ t j |  t d   | j   Wd  QXd t _ t j |  t d   | j   Wd  QXd  S(   Nt   usernamet
   testclients3   You need to set AUTH_PROFILE_MODULE in your projectt   foobars5   app_label and model_name should be separated by a dots   foo.bars    Unable to load the profile model(	   R   t   objectst   createR    R   R	   t   assertRaisesRegexR   t   get_profile(   t   selft   user(    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   test_site_profile_not_available   s    
	
	
(   t   __name__t
   __module__R   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyR      s   t   NaturalKeysTestCasec           B   s#   e  Z d  g Z d   Z d   Z RS(   s   authtestdata.jsonc         C   sK   t  j j d d  } |  j t  j j d  |  |  j | j   d  d  S(   NR   t   staff(   R   (   R   R   t   gett   assertEqualt   get_by_natural_keyt   natural_key(   R   t
   staff_user(    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   test_user_natural_key*   s    c         C   s5   t  j j d d  } |  j t  j j d  |  d  S(   Nt   namet   users(   R   R   R   R   R   (   R   t   users_group(    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   test_group_natural_key/   s    (   R   R   t   fixturesR!   R%   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyR   %   s   		t"   LoadDataWithoutNaturalKeysTestCasec           B   s   e  Z d  g Z d   Z RS(   s   regular.jsonc         C   sG   t  j j d d  } t j j d d  } |  j | | j j    d  S(   NR   t   my_usernameR"   t   my_group(   R   R   R   R   R   t   groups(   R   R   t   group(    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt'   test_user_is_created_and_added_to_group9   s    (   R   R   R&   R,   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyR'   4   s   	t   LoadDataWithNaturalKeysTestCasec           B   s   e  Z d  g Z d   Z RS(   s   natural.jsonc         C   sG   t  j j d d  } t j j d d  } |  j | | j j    d  S(   NR   R(   R"   R)   (   R   R   R   R   R   R*   (   R   R   R+   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyR,   D   s    (   R   R   R&   R,   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyR-   ?   s   	t   UserManagerTestCasec           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   sX   d } t  j j d |  } |  j | j |  |  j | j d  |  j | j d  d  S(   Ns   normal@normal.comR   t   !(   R   R   t   create_userR   t   emailR   t   password(   R   t   email_lowercaseR   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   test_create_userM   s
    c         C   s#   t  j d  } |  j | d  d  S(   Ns   Abc\@DEF@EXAMPLE.coms   Abc\@DEF@example.com(   R   t   normalize_emailR   (   R   t   returned(    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt/   test_create_user_email_domain_normalize_rfc3696T   s    c         C   s#   t  j d  } |  j | d  d  S(   Ns   normal@DOMAIN.COMs   normal@domain.com(   R   R5   R   (   R   R6   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt'   test_create_user_email_domain_normalizeZ   s    c         C   s#   t  j d  } |  j | d  d  S(   Ns   email\ with_whitespace@D.COMs   email\ with_whitespace@d.com(   R   R5   R   (   R   R6   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt7   test_create_user_email_domain_normalize_with_whitespace^   s    c         C   s#   |  j  t d t j j d d d  S(   Ns   The given username must be setR   R   (   t   assertRaisesMessaget
   ValueErrorR   R   R0   (   R   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   test_empty_usernameb   s    	(   R   R   R4   R7   R8   R9   R<   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyR.   J   s
   				t   IsActiveTestCasec           B   s5   e  Z d  Z e d    Z e d d  d    Z RS(   sB   
    Tests the behavior of the guaranteed is_active attribute
    c         C   sm   t  j j d d d d  } |  j | j t  t | _ | j   t  j j d | j	  } |  j
 | j  d  S(   NR   t   fooR1   s   foo@bar.comt   pk(   R   R   R   R   t	   is_activet   Truet   Falset   saveR   R?   t   assertFalse(   R   R   t   user_fetched(    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   test_builtin_user_isactivem   s    	
t   AUTH_USER_MODELs   auth.IsActiveTestUser1c         C   sm   t    } | d d  } |  j | j t  t | _ | j   | j j d | j  } |  j | j t  d S(   sH   
        tests that the default value for is_active is provided
        R   R>   R?   N(	   R   R   R@   RA   RB   RC   t   _default_managerR   R?   (   R   t	   UserModelR   RE   (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   test_is_active_field_defaultx   s    		
(   R   R   t   __doc__R   RF   R   RJ   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyR=   h   s   N(   t   django.confR    t   django.contrib.authR   t   django.contrib.auth.modelsR   R   R   R   t   django.contrib.auth.tests.utilsR   t   django.testR   t   django.test.utilsR   t   django.utilsR	   RB   R   R   R'   R-   R.   R=   (    (    (    s9   ../Django//lib/python/django/contrib/auth/tests/models.pyt   <module>   s*   "		