2012-09-04 12 views
1

장고 1.3을 장고 라이브 서버 1.3에 백 포트하여 1.3을 사용하고 있습니다. 그것은 잘 때, 내가 Django LiverserverTestCase documentaion 에서 튜토리얼을하고 있었지만 django 1.3에 대한 수입과 함께 일했다. "/ admin /" 페이지를 테스트했지만 괜찮 았지만 내 URL을 테스트하려고 할 때 심지어 "/" 일 뿐이므로 관리자에게 다시 전송됩니다! 왜? Google에서 단서를 찾지 못했습니다. 아마도이 문제는 하나뿐입니다.Django 셀레늄 라이브 서버가 관리 사이트로 리디렉션됩니다.

어쩌면 내가 서버의 일부 설정을 해산했다.하지만 localhost : 8000/test는 runserver 명령 후에 잘 작동한다.

누군가가 이런 유형의 문제가 있었다면 대답하십시오. 응용 프로그램의

from django_liveserver.testcases import LiveServerTestCase 
from selenium.webdriver.firefox.webdriver import WebDriver 
from selenium.webdriver.support.wait import WebDriverWait 
from selenium import webdriver 

class MySeleniumTests(LiveServerTestCase): 
fixtures = ['nstein/test-users.json'] 

@classmethod 
def setUpClass(cls): 
    cls.selenium = WebDriver() 
    cls.selenium.implicitly_wait(3) 
    super(MySeleniumTests, cls).setUpClass() 

@classmethod 
def tearDownClass(cls): 
    super(MySeleniumTests, cls).tearDownClass() 
    cls.selenium.quit() 

def test_login(self): 

    self.selenium.get('%s%s' % (self.live_server_url. '/admin/')) 
    body = self.selenium.find_element_by_tag_name('body') 
    self.assertIn('Username', body.text) 
    username_input = self.selenium.find_element_by_id("id_username") 
    password_input = self.selenium.find_element_by_id("id_password") 
    password_input.send_keys('123') 
    username_input.send_keys('admin') 
    password_input.clear() 
    self.selenium.find_element_by_xpath('//input[@value="Log in"]').click() 
    body = self.selenium.find_element_by_tag_name('body') 
    self.assertIn('Site administration', body.text) 
    # url is in the urls.py of the app, 
    #selenium gets response 302 but redirects to /admin/ 
    self.selenium.get('%s%s' % (self.live_server_url. '/test/')) 

urls.py :

#from cms import sitemaps 
from django.conf.urls.defaults import * 
from django.conf import settings 
from django.contrib.staticfiles.urls import staticfiles_urlpatterns 
from hitcount.views import update_hit_count_ajax 
from django.views.generic.simple import direct_to_template 

import dselector 
from wcms.furniture_today.views import * 

parser = dselector.Parser() 

urlpatterns = patterns('', 
parser.url(r'^test/$', direct_to_template, {'template': 'index.html'}, 'index'), 
) 

세계의 URL :

from django.conf.urls.defaults import * 
from django.conf import settings 
from django.contrib.staticfiles.urls import staticfiles_urlpatterns 
from wcms.business.views import wcms_admin_redirect 

urlpatterns = patterns('', 
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), 
url(r'^', include('wcms.admin_urls')), 
url(r'^', wcms_admin_redirect), 
url(r'^', include('cms.urls')), 
) 

if settings.DEBUG: # assuming dev server 
urlpatterns += patterns('', (r'^' + settings.MEDIA_URL.lstrip('/'), include('appmedia.urls'))) 

urlpatterns += staticfiles_urlpatterns() 
+2

URL을 게시하시기 바랍니다 –

+0

완료에 self.selenium.get('%s%s' % (self.live_server_url. '/test/'))을 넣어보십시오 . 질문에 추가됨 – Feanor

답변

1

새로운 기능

def test_two(self): 
    self.selenium.get('%s%s' % (self.live_server_url. '/test/')) 
관련 문제