U
    Be;	                     @   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
    NZtwythonAuthenticatec                   C   s   t  S )Nr    r   r   |/var/www/nmhs-web.org.in/public_html/infoladakh/backend/venv/lib/python3.8/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 tdS )zI
        Test that environment variable has been read correctly.
        r	   N)r
   r   basenameZcreds_subdirr   AssertionError)r   r   fnr   r   r   test_environment   s    z TestCredentials.test_environmentkwargsr    Nz
/nosuchdir
creds_fileZfoobarzbad_oauth1-1.txtzbad_oauth1-2.txtzbad_oauth1-3.txtc              
   C   sf   z|j f | W nF ttfk
r(   Y n: tk
rV } ztd|  W 5 d}~X Y nX td dS )z, Various scenarios that should raise errors zUnexpected exception thrown: %sNzOSError exception not thrown.)
load_credsOSError
ValueError	ExceptionpytestZ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*t|jdks8t|d dksHtdS )z8 Test that a proper file succeeds and is read correctly )r   zcredentials.txtZapp_keyaN)r   r   Zcreds_fullpathr
   r   r   r   r   )r   r   Zoauthr   r   r   test_correct_fileC   s    z!TestCredentials.test_correct_file)__name__
__module____qualname____doc__classmethodr   r   r   markZparametrizer    r"   r   r   r   r   r      s    

r   )	r&   r
   r   ZimportorskipZnltk.twitterr   Zfixturer   r   r   r   r   r   <module>   s   

