
    g	                         d Z ddlZddlZ ej                  d       ddlmZ ej                  d        Z G d d      Zy)z+
Tests for static parts of Twitter package
    NtwythonAuthenticatec                      t               S )Nr        U/var/www/openai/venv/lib/python3.12/site-packages/nltk/test/unit/test_twitter_auth.pyauthr
      s
    >r   c                       e Zd ZdZed        Zd Zej                  j                  dddiddiddii d	d
id	did	did	dig      d        Z
d Zy)TestCredentialszK
    Tests that Twitter credentials from a file are handled correctly.
    c                     t         j                  j                  t         j                  j                  t              d      | _        dt         j                  d<   y )Nfilesztwitter-filesTWITTER)ospathjoindirname__file__subdirenviron)selfs    r	   setup_classzTestCredentials.setup_class   s3    ggll277??8#<gF /

9r   c                     t         j                  j                  |j                        }|t         j                  d   k(  sJ y)zI
        Test that environment variable has been read correctly.
        r   N)r   r   basenamecreds_subdirr   )r   r
   fns      r	   test_environmentz TestCredentials.test_environment   s5     WWd//0RZZ	****r   kwargsr    Nz
/nosuchdir
creds_filefoobarzbad_oauth1-1.txtzbad_oauth1-2.txtzbad_oauth1-3.txtc                     	  |j                   di | t        j                  d       y# t        t        f$ r Y yt
        $ r"}t        j                  d|z         Y d}~yd}~ww xY w)z*Various scenarios that should raise errorszOSError exception not thrown.zUnexpected exception thrown: %sNr   )
load_credspytestfailOSError
ValueError	Exception)r   r   r
   es       r	   'test_scenarios_that_should_raise_errorsz7TestCredentials.test_scenarios_that_should_raise_errors$   s^    0		9DOO%f% KK78 $ 	 	?KK9A=>>	?s   * A%A%A  A%c                     |j                  | j                        }|j                  t        j                  j                  | j                  |j                        k(  sJ |j                  dk(  sJ |d   dk(  sJ y)z6Test that a proper file succeeds and is read correctly)r   zcredentials.txtapp_keyaN)r#   r   creds_fullpathr   r   r   r    )r   r
   oauths      r	   test_correct_filez!TestCredentials.test_correct_fileG   sg    t{{3""bggll4;;&PPPP"3333Y3&&&r   )__name__
__module____qualname____doc__classmethodr   r   r$   markparametrizer*   r0   r   r   r	   r   r      s     0 0+ [[ rNt|$8$-.-.-.#	
,9-,9'r   r   )	r4   r   r$   importorskipnltk.twitterr   fixturer
   r   r   r   r	   <module>r;      sG    
    I  %  :' :'r   