Updated test suites
This commit is contained in:
parent
cbabafb492
commit
a39e51e1f5
8 changed files with 46 additions and 59 deletions
|
|
@ -5,11 +5,9 @@ from housewars.utils import get_random_string
|
|||
|
||||
class GetRandomStringTest(TestCase):
|
||||
def test_string_of_length_8(self):
|
||||
"""The string generated is of the correct length"""
|
||||
string = get_random_string(8)
|
||||
self.assertEqual(len(string), 8)
|
||||
|
||||
def test_string_of_length_6(self):
|
||||
"""The string generated is of the correct length"""
|
||||
string = get_random_string(6)
|
||||
self.assertEqual(len(string), 6)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class UnpackValuesTest(TestCase):
|
|||
self.test_queryset = House.objects.all()
|
||||
|
||||
def test_matching_object_instance(self):
|
||||
"""Correctly unpacks the headers into the first index"""
|
||||
headers = [field.name for field in House._meta.fields]
|
||||
|
||||
self.assertIsInstance(
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ class UnpackValuesTest(TestCase):
|
|||
self.test_queryset = House.objects.all()
|
||||
|
||||
def test_valid_row_headers(self):
|
||||
"""Correctly unpacks the headers into the first index"""
|
||||
headers = [field.name for field in House._meta.fields]
|
||||
|
||||
values = unpack_values(self.test_queryset, headers)
|
||||
|
|
@ -20,7 +19,6 @@ class UnpackValuesTest(TestCase):
|
|||
values[0], headers)
|
||||
|
||||
def test_complete_values(self):
|
||||
"""Maintains the complete queryset and returns it"""
|
||||
headers = [field.name for field in House._meta.fields]
|
||||
values = unpack_values(self.test_queryset, headers)
|
||||
queryset = list(self.test_queryset.values_list())
|
||||
|
|
|
|||
|
|
@ -60,9 +60,3 @@ class UserEntryCreateViewTest(TestCase):
|
|||
self.client.post(self.url, data)
|
||||
|
||||
self.assertEquals(self.house.userentry_set.count(), 0)
|
||||
|
||||
def test_empty_POST(self):
|
||||
response = self.client.post(self.url)
|
||||
|
||||
self.assertEquals(response.status_code, 400)
|
||||
self.assertEquals(self.house.pointsentry_set.count(), 0)
|
||||
|
|
|
|||
|
|
@ -1,33 +1,29 @@
|
|||
asgiref==3.5.2
|
||||
async-generator==1.10
|
||||
attrs==22.1.0
|
||||
autopep8==1.6.0
|
||||
certifi==2022.6.15
|
||||
charset-normalizer==2.1.1
|
||||
Django==4.0.4
|
||||
django-formtools==2.3
|
||||
asgiref==3.7.2
|
||||
attrs==23.2.0
|
||||
certifi==2024.2.2
|
||||
chardet==5.2.0
|
||||
charset-normalizer==3.3.2
|
||||
Django==4.2.10
|
||||
django-formtools==2.5.1
|
||||
django-smart-selects==1.6.0
|
||||
gunicorn==20.1.0
|
||||
h11==0.13.0
|
||||
idna==3.3
|
||||
mysqlclient==2.1.1
|
||||
outcome==1.2.0
|
||||
Pillow==9.2.0
|
||||
pycodestyle==2.8.0
|
||||
h11==0.14.0
|
||||
idna==3.6
|
||||
mysqlclient==2.2.4
|
||||
outcome==1.3.0.post0
|
||||
packaging==23.2
|
||||
pillow==10.2.0
|
||||
PySocks==1.7.1
|
||||
python-dotenv==0.20.0
|
||||
reportlab==3.6.11
|
||||
requests==2.28.1
|
||||
python-dotenv==1.0.1
|
||||
reportlab==4.1.0
|
||||
requests==2.31.0
|
||||
selenium==4.4.3
|
||||
sniffio==1.3.0
|
||||
sortedcontainers==2.4.0
|
||||
sqlparse==0.4.2
|
||||
toml==0.10.2
|
||||
tqdm==4.64.1
|
||||
trio==0.21.0
|
||||
trio-websocket==0.9.2
|
||||
tzdata==2022.1
|
||||
urllib3==1.26.12
|
||||
webdriver-manager==3.8.3
|
||||
whitenoise==6.2.0
|
||||
sqlparse==0.4.4
|
||||
trio==0.24.0
|
||||
trio-websocket==0.11.1
|
||||
typing_extensions==4.9.0
|
||||
urllib3==1.26.18
|
||||
webdriver-manager==4.0.1
|
||||
whitenoise==6.6.0
|
||||
wsproto==1.2.0
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
from django.urls import reverse
|
||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||
|
||||
from selenium.webdriver import Chrome
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver import Chrome, ChromeOptions
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
|
@ -12,10 +11,10 @@ from webdriver_manager.chrome import ChromeDriverManager
|
|||
from housewars.models import Activity
|
||||
|
||||
|
||||
class UserEntryCreatePageTest(StaticLiveServerTestCase):
|
||||
class FacilitatorEntry(StaticLiveServerTestCase):
|
||||
def setUp(self):
|
||||
# Headless chrome driver test setup
|
||||
options = Options()
|
||||
options = ChromeOptions()
|
||||
options.add_argument('--headless')
|
||||
options.add_argument('--start-maximized')
|
||||
options.add_argument('--disable-gpu')
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
from django.urls import reverse
|
||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||
|
||||
from selenium.webdriver import Chrome
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from webdriver_manager.chrome import ChromeDriverManager
|
||||
from selenium.webdriver import Chrome, ChromeOptions
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
from selenium.webdriver.support.select import Select
|
||||
from selenium.webdriver.support.expected_conditions import visibility_of
|
||||
from webdriver_manager.chrome import ChromeDriverManager
|
||||
|
||||
from housewars.models import House, Activity, Award
|
||||
|
||||
import time
|
||||
|
||||
class UserEntryCreatePageTest(StaticLiveServerTestCase):
|
||||
|
||||
class PointsEntryCreatePageTest(StaticLiveServerTestCase):
|
||||
def setUp(self):
|
||||
# Headless chrome driver test setup
|
||||
options = Options()
|
||||
options = ChromeOptions()
|
||||
options.add_argument('--headless')
|
||||
options.add_argument('--start-maximized')
|
||||
options.add_argument('--disable-gpu')
|
||||
|
|
@ -35,16 +36,19 @@ class UserEntryCreatePageTest(StaticLiveServerTestCase):
|
|||
self.browser.get(self.url)
|
||||
|
||||
# Wait until browser loads page before continuing
|
||||
WebDriverWait(self.browser, timeout=5).until(
|
||||
visibility_of(self.browser.find_element(By.ID, 'header')))
|
||||
WebDriverWait(self.browser, timeout=5).until(visibility_of(self.browser.find_element(By.ID, 'header')))
|
||||
|
||||
# Fill in form with valid inputs
|
||||
Select(self.browser.find_element(By.ID, 'id_activity')
|
||||
).select_by_visible_text('Dodgeball - 30 min')
|
||||
Select(self.browser.find_element(By.ID, 'house')
|
||||
).select_by_visible_text('Hawk')
|
||||
Select(self.browser.find_element(By.ID, 'id_award')
|
||||
).select_by_visible_text('1st')
|
||||
Select(self.browser.find_element(By.ID, 'id_activity')).select_by_visible_text('Dodgeball - 30 min')
|
||||
Select(self.browser.find_element(By.ID, 'house')).select_by_visible_text('Hawk')
|
||||
|
||||
# Wait until the Select button with '1st' shows up
|
||||
WebDriverWait(self.browser, timeout=5).until(visibility_of(
|
||||
self.browser.find_element(By.XPATH, "//option[text()='1st']")))
|
||||
|
||||
time.sleep(0.25)
|
||||
|
||||
Select(self.browser.find_element(By.ID, 'id_award')).select_by_visible_text('1st')
|
||||
self.browser.find_element(By.ID, 'submit').click()
|
||||
|
||||
# Verify that success message is shown
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
from django.urls import reverse
|
||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||
|
||||
from selenium.webdriver import Chrome
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver import Chrome, ChromeOptions
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
|
@ -16,12 +15,12 @@ from housewars.models import House, Activity, UserEntry
|
|||
class UserEntryCreatePageTest(StaticLiveServerTestCase):
|
||||
def setUp(self):
|
||||
# Headless chrome driver test setup
|
||||
options = Options()
|
||||
options = ChromeOptions()
|
||||
options.add_argument('--headless')
|
||||
options.add_argument('--start-maximized')
|
||||
options.add_argument('--disable-gpu')
|
||||
self.browser = Chrome(
|
||||
ChromeDriverManager().install(), chrome_options=options)
|
||||
ChromeDriverManager().install(), options=options)
|
||||
self.url = self.live_server_url + reverse('housewars:signup')
|
||||
|
||||
# Initial data setup
|
||||
|
|
|
|||
Reference in a new issue