o
    Mf	                     @   sJ   d Z ddlZddlZed ddlmZ ejdd ZG dd dZdS )	z+
Tests for static parts of Twitter package
    NtwythonAuthenticatec                   C   s   t  S )Nr    r   r   b/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/nltk/test/unit/test_twitter_auth.pyauth   s   r   c                   @   sn   e Zd ZdZedd Zdd Ze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d Z
dd Zd	S )TestCredentialszK
    Tests that Twitter credentials from a file are handled correctly.
    c                 C   s&   t jt jtd| _dt jd< d S )Nfilesztwitter-filesTWITTER)ospathjoindirname__file__subdirenviron)selfr   r   r   setup_class   s   zTestCredentials.setup_classc                 C   s$   t j|j}|t jd ksJ dS )zI
        Test that environment variable has been read correctly.
        r
   N)r   r   basenamecreds_subdirr   )r   r   fnr   r   r   test_environment   s   z TestCredentials.test_environmentkwargsr    Nz
/nosuchdir
creds_filefoobarzbad_oauth1-1.txtzbad_oauth1-2.txtzbad_oauth1-3.txtc              
   C   sn   z
|j di | W n% ttfy   Y dS  ty/ } ztd|  W Y d}~dS d}~ww td dS )z*Various scenarios that should raise errorszUnexpected exception thrown: %sNzOSError exception not thrown.r   )
load_credsOSError
ValueError	Exceptionpytestfail)r   r   r   er   r   r   'test_scenarios_that_should_raise_errors$   s   z7TestCredentials.test_scenarios_that_should_raise_errorsc                 C   sL   |j | jd}|jtj| j|jksJ |jdksJ |d dks$J dS )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   oauthr   r   r   test_correct_fileG   s   z!TestCredentials.test_correct_file)__name__
__module____qualname____doc__classmethodr   r   r    markparametrizer#   r(   r   r   r   r   r      s&    

r   )	r,   r   r    importorskipnltk.twitterr   fixturer   r   r   r   r   r   <module>   s    

