add tests
This commit is contained in:
@@ -8,21 +8,28 @@ from django.contrib.auth import (
|
||||
)
|
||||
from django.contrib.sessions.backends.db import SessionStore
|
||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||
from django.urls import reverse
|
||||
from selenium import webdriver
|
||||
|
||||
USER = get_user_model().objects.get(pk=2)
|
||||
vcr_options = {
|
||||
"path": "teamsnap/fixtures/tests.json",
|
||||
"ignore_localhost": True,
|
||||
"filter_headers": ["authorization"],
|
||||
"filter_query_parameters": ["email", "password"],
|
||||
# 'record_mode':"new_episodes",
|
||||
"decode_compressed_response": True,
|
||||
"allow_playback_repeats": True,
|
||||
}
|
||||
|
||||
|
||||
def create_session_cookie():
|
||||
|
||||
# First, create a new test user
|
||||
user = get_user_model()
|
||||
# user.objects.create_user(username=username, password=password)
|
||||
user = get_user_model().objects.get(pk=2)
|
||||
|
||||
# Then create the authenticated session using the new user credentials
|
||||
session = SessionStore()
|
||||
session[SESSION_KEY] = user.pk
|
||||
session[SESSION_KEY] = USER.pk
|
||||
session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
|
||||
session[HASH_SESSION_KEY] = user.get_session_auth_hash()
|
||||
session[HASH_SESSION_KEY] = USER.get_session_auth_hash()
|
||||
session.save()
|
||||
|
||||
# Finally, create the cookie dictionary
|
||||
@@ -35,7 +42,7 @@ def create_session_cookie():
|
||||
return cookie
|
||||
|
||||
|
||||
class TeamsnapDashboardTests(StaticLiveServerTestCase):
|
||||
class TeamsnapTests(StaticLiveServerTestCase):
|
||||
fixtures = ["benchcoach/fixtures/dump.json"]
|
||||
|
||||
@classmethod
|
||||
@@ -57,18 +64,10 @@ class TeamsnapDashboardTests(StaticLiveServerTestCase):
|
||||
self.selenium.refresh()
|
||||
pass
|
||||
|
||||
@vcr.use_cassette(
|
||||
"teamsnap/dashboard/fixtures/tests.yaml",
|
||||
ignore_localhost=True,
|
||||
# record_mode="new_episodes",
|
||||
decode_compressed_response=True,
|
||||
allow_playback_repeats=True,
|
||||
)
|
||||
@vcr.use_cassette(**vcr_options)
|
||||
def test_dashboard(self):
|
||||
self.selenium.get(
|
||||
"{url}/{team_id}/dashboard/".format(
|
||||
url=self.live_server_url,
|
||||
team_id=6882652,
|
||||
)
|
||||
)
|
||||
managed_team_id = USER.teamsnap_preferences.managed_team_id
|
||||
# event_id = 266446202
|
||||
url = reverse("teamsnap_dashboard", kwargs=dict(team_id=managed_team_id))
|
||||
self.selenium.get(url=self.live_server_url + url)
|
||||
breakpoint()
|
||||
|
||||
Reference in New Issue
Block a user