"""Pylons application test packageThis package assumes the Pylons environment is already loaded, such aswhen this script is imported from the `nosetests --with-pylons=test.ini`command.This module initializes the application via ``websetup`` (`pastersetup-app`) and provides the base testing objects."""fromunittestimportTestCasefrompaste.deployimportloadappfrompaste.script.appinstallimportSetupCommandfrompylonsimportconfig,urlfromroutes.utilimportURLGeneratorfromwebtestimportTestAppimportosfromrhodecode.modelimportmetaimportlogginglog=logging.getLogger(__name__)importpylons.test__all__=['environ','url','TestController']# Invoke websetup with the current config file#SetupCommand('setup-app').run([config_file])##RUNNING DESIRED TESTS#nosetests rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_accountenviron={}classTestController(TestCase):def__init__(self,*args,**kwargs):wsgiapp=pylons.test.pylonsappconfig=wsgiapp.configself.app=TestApp(wsgiapp)url._push_object(URLGenerator(config['routes.map'],environ))self.sa=meta.SessionTestCase.__init__(self,*args,**kwargs)deflog_user(self,username='test_admin',password='test12'):response=self.app.post(url(controller='login',action='index'),{'username':username,'password':password})printresponseif'invalid user name'inresponse.body:assertFalse,'could not login using %s%s'%(username,password)assertresponse.status=='302 Found','Wrong response code from login got %s'%response.statusassertresponse.session['rhodecode_user'].username==username,'wrong logged in user got %s expected %s'%(response.session['rhodecode_user'].username,username)returnresponse.follow()