add tests
This commit is contained in:
@@ -1,3 +1,77 @@
|
|||||||
# from django.test import TestCase
|
import vcr
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.auth import (
|
||||||
|
BACKEND_SESSION_KEY,
|
||||||
|
HASH_SESSION_KEY,
|
||||||
|
SESSION_KEY,
|
||||||
|
get_user_model,
|
||||||
|
)
|
||||||
|
from django.contrib.sessions.backends.db import SessionStore
|
||||||
|
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||||
|
from selenium import webdriver
|
||||||
|
|
||||||
# Create your tests here.
|
vcr_options = {
|
||||||
|
"path": "gamecard/fixtures/test.yaml",
|
||||||
|
"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[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
|
||||||
|
session[HASH_SESSION_KEY] = user.get_session_auth_hash()
|
||||||
|
session.save()
|
||||||
|
|
||||||
|
# Finally, create the cookie dictionary
|
||||||
|
cookie = {
|
||||||
|
"name": settings.SESSION_COOKIE_NAME,
|
||||||
|
"value": session.session_key,
|
||||||
|
"secure": False,
|
||||||
|
"path": "/",
|
||||||
|
}
|
||||||
|
return cookie
|
||||||
|
|
||||||
|
|
||||||
|
class GamecardTests(StaticLiveServerTestCase):
|
||||||
|
fixtures = ["benchcoach/fixtures/dump.json"]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.port = 8000
|
||||||
|
super().setUpClass()
|
||||||
|
cls.selenium = webdriver.Chrome("/opt/homebrew/bin/chromedriver")
|
||||||
|
cls.selenium.implicitly_wait(10)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.selenium.quit()
|
||||||
|
super().tearDownClass()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
session_cookie = create_session_cookie()
|
||||||
|
self.selenium.get("{}{}".format(self.live_server_url, "/"))
|
||||||
|
self.selenium.add_cookie(session_cookie)
|
||||||
|
self.selenium.refresh()
|
||||||
|
pass
|
||||||
|
|
||||||
|
@vcr.use_cassette(**vcr_options)
|
||||||
|
def test_gamecard(self):
|
||||||
|
self.selenium.get(
|
||||||
|
"{url}/{team_id}/event/{event_id}/gamecard/".format(
|
||||||
|
url=self.live_server_url, team_id=6882652, event_id=266446202
|
||||||
|
)
|
||||||
|
)
|
||||||
|
breakpoint()
|
||||||
|
|||||||
@@ -8,21 +8,28 @@ from django.contrib.auth import (
|
|||||||
)
|
)
|
||||||
from django.contrib.sessions.backends.db import SessionStore
|
from django.contrib.sessions.backends.db import SessionStore
|
||||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||||
|
from django.urls import reverse
|
||||||
from selenium import webdriver
|
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():
|
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
|
# Then create the authenticated session using the new user credentials
|
||||||
session = SessionStore()
|
session = SessionStore()
|
||||||
session[SESSION_KEY] = user.pk
|
session[SESSION_KEY] = USER.pk
|
||||||
session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
|
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()
|
session.save()
|
||||||
|
|
||||||
# Finally, create the cookie dictionary
|
# Finally, create the cookie dictionary
|
||||||
@@ -35,7 +42,7 @@ def create_session_cookie():
|
|||||||
return cookie
|
return cookie
|
||||||
|
|
||||||
|
|
||||||
class TeamsnapDashboardTests(StaticLiveServerTestCase):
|
class TeamsnapTests(StaticLiveServerTestCase):
|
||||||
fixtures = ["benchcoach/fixtures/dump.json"]
|
fixtures = ["benchcoach/fixtures/dump.json"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -57,18 +64,10 @@ class TeamsnapDashboardTests(StaticLiveServerTestCase):
|
|||||||
self.selenium.refresh()
|
self.selenium.refresh()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@vcr.use_cassette(
|
@vcr.use_cassette(**vcr_options)
|
||||||
"teamsnap/dashboard/fixtures/tests.yaml",
|
|
||||||
ignore_localhost=True,
|
|
||||||
# record_mode="new_episodes",
|
|
||||||
decode_compressed_response=True,
|
|
||||||
allow_playback_repeats=True,
|
|
||||||
)
|
|
||||||
def test_dashboard(self):
|
def test_dashboard(self):
|
||||||
self.selenium.get(
|
managed_team_id = USER.teamsnap_preferences.managed_team_id
|
||||||
"{url}/{team_id}/dashboard/".format(
|
# event_id = 266446202
|
||||||
url=self.live_server_url,
|
url = reverse("teamsnap_dashboard", kwargs=dict(team_id=managed_team_id))
|
||||||
team_id=6882652,
|
self.selenium.get(url=self.live_server_url + url)
|
||||||
)
|
|
||||||
)
|
|
||||||
breakpoint()
|
breakpoint()
|
||||||
|
|||||||
@@ -1,3 +1,77 @@
|
|||||||
# from django.test import TestCase
|
import vcr
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.auth import (
|
||||||
|
BACKEND_SESSION_KEY,
|
||||||
|
HASH_SESSION_KEY,
|
||||||
|
SESSION_KEY,
|
||||||
|
get_user_model,
|
||||||
|
)
|
||||||
|
from django.contrib.sessions.backends.db import SessionStore
|
||||||
|
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||||
|
from django.urls import reverse
|
||||||
|
from selenium import webdriver
|
||||||
|
|
||||||
# Create your tests here.
|
vcr_options = {
|
||||||
|
"user" "path": "teamsnap/lineup/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,
|
||||||
|
}
|
||||||
|
|
||||||
|
USER = get_user_model().objects.get(pk=2)
|
||||||
|
|
||||||
|
|
||||||
|
def create_session_cookie():
|
||||||
|
|
||||||
|
# Then create the authenticated session using the new user credentials
|
||||||
|
session = SessionStore()
|
||||||
|
session[SESSION_KEY] = USER.pk
|
||||||
|
session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
|
||||||
|
session[HASH_SESSION_KEY] = USER.get_session_auth_hash()
|
||||||
|
session.save()
|
||||||
|
|
||||||
|
# Finally, create the cookie dictionary
|
||||||
|
cookie = {
|
||||||
|
"name": settings.SESSION_COOKIE_NAME,
|
||||||
|
"value": session.session_key,
|
||||||
|
"secure": False,
|
||||||
|
"path": "/",
|
||||||
|
}
|
||||||
|
return cookie
|
||||||
|
|
||||||
|
|
||||||
|
class TeamsnapLineupTests(StaticLiveServerTestCase):
|
||||||
|
fixtures = ["benchcoach/fixtures/dump.json", "gamechanger/fixtures/dump.json"]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.port = 8000
|
||||||
|
super().setUpClass()
|
||||||
|
cls.selenium = webdriver.Chrome("/opt/homebrew/bin/chromedriver")
|
||||||
|
cls.selenium.implicitly_wait(10)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.selenium.quit()
|
||||||
|
super().tearDownClass()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
session_cookie = create_session_cookie()
|
||||||
|
self.selenium.get("{}{}".format(self.live_server_url, "/"))
|
||||||
|
self.selenium.add_cookie(session_cookie)
|
||||||
|
self.selenium.refresh()
|
||||||
|
pass
|
||||||
|
|
||||||
|
@vcr.use_cassette(**vcr_options)
|
||||||
|
def test_teamsnap_lineup(self):
|
||||||
|
managed_team_id = USER.teamsnap_preferences.managed_team_id
|
||||||
|
event_id = 266446202
|
||||||
|
url = reverse(
|
||||||
|
"teamsnap_edit_lineup",
|
||||||
|
kwargs=dict(team_id=managed_team_id, event_ids=event_id),
|
||||||
|
)
|
||||||
|
self.selenium.get(url=self.live_server_url + url)
|
||||||
|
breakpoint()
|
||||||
|
|||||||
@@ -8,21 +8,28 @@ from django.contrib.auth import (
|
|||||||
)
|
)
|
||||||
from django.contrib.sessions.backends.db import SessionStore
|
from django.contrib.sessions.backends.db import SessionStore
|
||||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||||
|
from django.urls import reverse
|
||||||
from selenium import webdriver
|
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():
|
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
|
# Then create the authenticated session using the new user credentials
|
||||||
session = SessionStore()
|
session = SessionStore()
|
||||||
session[SESSION_KEY] = user.pk
|
session[SESSION_KEY] = USER.pk
|
||||||
session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
|
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()
|
session.save()
|
||||||
|
|
||||||
# Finally, create the cookie dictionary
|
# Finally, create the cookie dictionary
|
||||||
@@ -35,7 +42,7 @@ def create_session_cookie():
|
|||||||
return cookie
|
return cookie
|
||||||
|
|
||||||
|
|
||||||
class MySeleniumTests(StaticLiveServerTestCase):
|
class TeamsnapTests(StaticLiveServerTestCase):
|
||||||
fixtures = ["benchcoach/fixtures/dump.json"]
|
fixtures = ["benchcoach/fixtures/dump.json"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -57,17 +64,10 @@ class MySeleniumTests(StaticLiveServerTestCase):
|
|||||||
self.selenium.refresh()
|
self.selenium.refresh()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@vcr.use_cassette(
|
@vcr.use_cassette(**vcr_options)
|
||||||
"teamsnap/lineup/fixtures/test.yaml",
|
def test_dashboard(self):
|
||||||
ignore_localhost=True,
|
managed_team_id = USER.teamsnap_preferences.managed_team_id
|
||||||
# record_mode="new_episodes",
|
# event_id = 266446202
|
||||||
decode_compressed_response=True,
|
url = reverse("teamsnap_dashboard", kwargs=dict(team_id=managed_team_id))
|
||||||
allow_playback_repeats=True,
|
self.selenium.get(url=self.live_server_url + url)
|
||||||
)
|
|
||||||
def test_login(self):
|
|
||||||
self.selenium.get(
|
|
||||||
"{url}/{team_id}/event/{event_ids}/edit_lineup/".format(
|
|
||||||
url=self.live_server_url, team_id=6882652, event_ids=266446202
|
|
||||||
)
|
|
||||||
)
|
|
||||||
breakpoint()
|
breakpoint()
|
||||||
|
|||||||
Reference in New Issue
Block a user