new functional_tests.container_commands file discerns local from server containers; .base calls now calls reset_database() therefrom; .test_my_lists also discerns test server location for different session keys; functional_tests restored as app in core.settings
This commit is contained in:
@@ -2,24 +2,25 @@ from django.conf import settings
|
||||
from django.contrib.auth import BACKEND_SESSION_KEY, SESSION_KEY, get_user_model
|
||||
from django.contrib.sessions.backends.db import SessionStore
|
||||
from .base import FunctionalTest
|
||||
from .container_commands import create_session_on_server
|
||||
from .management.commands.create_session import create_pre_authenticated_session
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class MyListsTest(FunctionalTest):
|
||||
def create_pre_authenticated_session(self, email):
|
||||
user = User.objects.create(email=email)
|
||||
session = SessionStore()
|
||||
session[SESSION_KEY] = user.pk
|
||||
session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
|
||||
session.save()
|
||||
if self.test_server:
|
||||
session_key = create_session_on_server(self.test_server, email)
|
||||
else:
|
||||
session_key = create_pre_authenticated_session(email)
|
||||
## to set a cookie we need to first visit the domain
|
||||
## 404 pages load the quickest!
|
||||
self.browser.get(self.live_server_url + "/404_no_such_url/")
|
||||
self.browser.add_cookie(
|
||||
dict(
|
||||
name=settings.SESSION_COOKIE_NAME,
|
||||
value=session.session_key,
|
||||
value=session_key,
|
||||
path="/",
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user