<s> from django . conf import settings <EOL> from django . core . urlresolvers import reverse <EOL> from django . test import TestCase <EOL> from django . test . client import Client <EOL> class WebmasterVerificationTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . client = Client ( ) <EOL> def test_google_file_access_and_content ( self ) : <EOL> if '<STR_LIT>' in settings . WEBMASTER_VERIFICATION : <EOL> codes = settings . WEBMASTER_VERIFICATION [ '<STR_LIT>' ] <EOL> if type ( codes ) == tuple : <EOL> for code in codes : <EOL> self . _test_google_file_access_and_content ( code ) <EOL> else : <EOL> self . _test_google_file_access_and_content ( codes ) <EOL> def _test_google_file_access_and_content ( self , code ) : <EOL> """<STR_LIT>""" <EOL> url = self . _get_google_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT:200> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> self . assertRegexpMatches ( <EOL> str ( r . content ) , <EOL> '<STR_LIT>' % code , <EOL> '<STR_LIT>' , <EOL> ) <EOL> def test_google_file_404s ( self ) : <EOL> bad_codes = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> for code in bad_codes : <EOL> url = self . _get_google_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> def _get_google_url ( self , code ) : <EOL> return '<STR_LIT>' % code <EOL> def test_bing_file_access_and_content ( self ) : <EOL> if '<STR_LIT>' in settings . WEBMASTER_VERIFICATION : <EOL> code = settings . WEBMASTER_VERIFICATION [ '<STR_LIT>' ] <EOL> url = '<STR_LIT>' <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT:200> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> self . assertEqual ( <EOL> r [ '<STR_LIT:Content-Type>' ] , <EOL> '<STR_LIT>' , <EOL> "<STR_LIT>" % r [ '<STR_LIT:Content-Type>' ] <EOL> ) <EOL> self . assertRegexpMatches ( <EOL> str ( r . content ) , <EOL> '<STR_LIT>' % code , <EOL> '<STR_LIT>' , <EOL> ) <EOL> def test_mj_file_access ( self ) : <EOL> if '<STR_LIT>' in settings . WEBMASTER_VERIFICATION : <EOL> codes = settings . WEBMASTER_VERIFICATION [ '<STR_LIT>' ] <EOL> if type ( codes ) == tuple : <EOL> for code in codes : <EOL> self . _test_mj_file_access ( code ) <EOL> else : <EOL> self . _test_mj_file_access ( codes ) <EOL> def _test_mj_file_access ( self , code ) : <EOL> url = self . _get_mj_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT:200> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> self . assertEqual ( <EOL> r [ '<STR_LIT:Content-Type>' ] , <EOL> '<STR_LIT>' , <EOL> "<STR_LIT>" % r [ '<STR_LIT:Content-Type>' ] <EOL> ) <EOL> def test_mj_file_404s ( self ) : <EOL> bad_codes = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> for code in bad_codes : <EOL> url = self . _get_mj_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> def _get_mj_url ( self , code ) : <EOL> return '<STR_LIT>' % code <EOL> def test_yandex_file_acces ( self ) : <EOL> if '<STR_LIT>' in settings . WEBMASTER_VERIFICATION : <EOL> codes = settings . WEBMASTER_VERIFICATION [ '<STR_LIT>' ] <EOL> if type ( codes ) == tuple : <EOL> for code in codes : <EOL> self . _test_yandex_file_access ( code ) <EOL> else : <EOL> self . _test_yandex_file_access ( codes ) <EOL> def _test_yandex_file_access ( self , code ) : <EOL> url = self . _get_yandex_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT:200> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> self . assertEqual ( <EOL> r [ '<STR_LIT:Content-Type>' ] , <EOL> '<STR_LIT>' , <EOL> "<STR_LIT>" % r [ '<STR_LIT:Content-Type>' ] <EOL> ) <EOL> def test_yandex_file_404s ( self ) : <EOL> bad_codes = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> for code in bad_codes : <EOL> url = self . _get_yandex_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> def _get_yandex_url ( self , code ) : <EOL> return '<STR_LIT>' % code <EOL> def test_alexa_file_acces ( self ) : <EOL> if '<STR_LIT>' in settings . WEBMASTER_VERIFICATION : <EOL> codes = settings . WEBMASTER_VERIFICATION [ '<STR_LIT>' ] <EOL> if type ( codes ) == tuple : <EOL> for code in codes : <EOL> self . _test_alexa_file_access ( code ) <EOL> else : <EOL> self . _test_alexa_file_access ( codes ) <EOL> def _test_alexa_file_access ( self , code ) : <EOL> url = self . _get_alexa_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT:200> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> def test_alexa_file_404s ( self ) : <EOL> bad_codes = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> for code in bad_codes : <EOL> url = self . _get_alexa_url ( code ) <EOL> r = self . client . get ( url ) <EOL> self . assertEqual ( <EOL> r . status_code , <EOL> <NUM_LIT> , <EOL> "<STR_LIT>" % ( url , r . status_code ) <EOL> ) <EOL> def _get_alexa_url ( self , code ) : <EOL> return '<STR_LIT>' % code </s>
