Skip to content

Commit

Permalink
Rename constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Muller committed Mar 5, 2024
1 parent 5189c4b commit 398bbc4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions wafer/schedule/tests/test_schedule_datetime_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.urls import reverse

from wafer.pages.models import Page
from wafer.tests.utils import ChromeTestRunner, FirefoxTestRunner, WAIT_TIME
from wafer.tests.utils import ChromeTestRunner, FirefoxTestRunner, SELENIUM_WAIT_TIME

from wafer.schedule.models import Venue, Slot, ScheduleBlock
from wafer.schedule.tests.test_views import make_pages, make_items
Expand Down Expand Up @@ -51,15 +51,15 @@ def setUp(self):
def check_clock_button(self):
"""Standard check for the clock button contents"""
# Find the clock button
clock_button = WebDriverWait(self.driver, WAIT_TIME).until(
clock_button = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, 'clock-icon'))
)
# Check that the list isn't visible before we click
clock_box = self.driver.find_element(By.ID, 'clockbox0')
style = clock_box.get_attribute('style')
self.assertIn('display: none', style)
clock_button.click()
timelist = WebDriverWait(self.driver, WAIT_TIME).until(
timelist = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, 'timelist'))
)
clock_box = self.driver.find_element(By.ID, 'clockbox0')
Expand Down
38 changes: 19 additions & 19 deletions wafer/schedule/tests/test_schedule_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from django.urls import reverse

from wafer.pages.models import Page
from wafer.tests.utils import create_user, ChromeTestRunner, FirefoxTestRunner, WAIT_TIME
from wafer.tests.utils import create_user, ChromeTestRunner, FirefoxTestRunner, SELENIUM_WAIT_TIME
from wafer.talks.tests.fixtures import create_talk
from wafer.talks.models import ACCEPTED

Expand Down Expand Up @@ -126,14 +126,14 @@ def _start(self):
"""Helper method to login as admin and load the editor"""
self.admin_login()
self.driver.get(self.edit_page)
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.TAG_NAME, "h1"))
)

def test_access_schedule_editor_no_login(self):
"""Test that the schedule editor isn't accessible if not logged in"""
self.driver.get(self.edit_page)
header = WebDriverWait(self.driver, WAIT_TIME).until(
header = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.TAG_NAME, "h1"))
)
self.assertEqual('Django administration', header.text)
Expand All @@ -148,10 +148,10 @@ def test_access_schedule_editor_no_super(self):
"""Test that the schedule editor isn't accessible for non-superuser accounts"""
self.normal_login()
self.driver.get(self.edit_page)
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.TAG_NAME, "h1"))
)
error = WebDriverWait(self.driver, WAIT_TIME).until(
error = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "errornote"))
)
self.assertIn("authenticated as normal", error.text)
Expand All @@ -163,7 +163,7 @@ def test_access_schedule_editor_no_super(self):
def test_access_schedule_editor_admin(self):
"""Test that the schedule editor is accessible for superuser accounts"""
self._start()
all_talks_link = WebDriverWait(self.driver, WAIT_TIME).until(
all_talks_link = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.PARTIAL_LINK_TEXT, "All Talks"))
)
all_talks_link.click()
Expand All @@ -180,7 +180,7 @@ def test_drag_talk(self):
self.assertEqual(ScheduleItem.objects.count(), 0)
self._start()
# partial link text to avoid whitespace fiddling
talks_link = WebDriverWait(self.driver, WAIT_TIME).until(
talks_link = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Unassigned Talks"))
)
talks_link.click()
Expand All @@ -202,7 +202,7 @@ def test_drag_talk(self):
# Pause briefly to make sure the server has a chance to do stuff
actions.pause(0.5)
actions.perform()
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "close"))
)
self.assertEqual(ScheduleItem.objects.count(), 1)
Expand All @@ -223,7 +223,7 @@ def test_drag_talk(self):
actions.drag_and_drop(source, target)
actions.pause(0.5)
actions.perform()
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "close"))
)
self.assertEqual(ScheduleItem.objects.count(), 2)
Expand All @@ -239,7 +239,7 @@ def test_drag_page(self):
self._start()
# Drag a page from the siderbar to a slot in the schedule

page_link = WebDriverWait(self.driver, WAIT_TIME).until(
page_link = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Pages"))
)
page_link.click()
Expand All @@ -262,7 +262,7 @@ def test_drag_page(self):
actions.drag_and_drop(source, target)
actions.pause(0.5)
actions.perform()
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "close"))
)
self.assertEqual(ScheduleItem.objects.count(), 1)
Expand All @@ -288,7 +288,7 @@ def test_drag_page(self):
actions.drag_and_drop(source, target)
actions.pause(0.5)
actions.perform()
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "close"))
)
self.assertEqual(ScheduleItem.objects.count(), 2)
Expand Down Expand Up @@ -332,7 +332,7 @@ def test_swicth_day(self):
# Load schedule page
self._start()
# Verify we see the expected schedule items on day 1
td1 = WebDriverWait(self.driver, WAIT_TIME).until(
td1 = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.ID, f"scheduleItem{item1.pk}"))
)
self.assertEqual(td1.tag_name, 'td')
Expand All @@ -344,12 +344,12 @@ def test_swicth_day(self):
buttons = self.driver.find_elements(By.TAG_NAME, 'button')
self.assertIn('Sep', buttons[1].text)
buttons[1].click()
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "show"))
)
days = self.driver.find_elements(By.PARTIAL_LINK_TEXT, "Sep")
days[1].click()
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "close"))
)
# Verify we see the expected schedule items on day 2
Expand All @@ -373,7 +373,7 @@ def test_drag_over_talk(self):
item1.save()
self._start()
# Test dragging a talk over an existing talk
target = WebDriverWait(self.driver, WAIT_TIME).until(
target = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.ID, f"scheduleItem{item1.pk}"))
)
talks_link = self.driver.find_element(By.PARTIAL_LINK_TEXT, "Unassigned Talks")
Expand Down Expand Up @@ -427,7 +427,7 @@ def test_drag_over_page(self):
item1.save()
self._start()
# Test dragging a page over an existing page
target = WebDriverWait(self.driver, WAIT_TIME).until(
target = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.ID, f"scheduleItem{item1.pk}"))
)
page_link = self.driver.find_element(By.PARTIAL_LINK_TEXT, "Pages")
Expand Down Expand Up @@ -477,7 +477,7 @@ def test_adding_clash(self):
item2.save()
self._start()
# Verify that there are no validation errors
validation = WebDriverWait(self.driver, WAIT_TIME).until(
validation = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "alert-danger"))
)
self.assertFalse(validation.is_displayed())
Expand Down Expand Up @@ -524,7 +524,7 @@ def test_removing_clash(self):
item2.save()
self._start()
# Verify that there are validation errors
validation = WebDriverWait(self.driver, WAIT_TIME).until(
validation = WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "alert-danger"))
)
self.assertTrue(validation.is_displayed())
Expand Down
6 changes: 3 additions & 3 deletions wafer/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def mock_avatar_url(self):


# Time to wait for elements to appear - single constant so we can easily tune it if needed
WAIT_TIME = 20
SELENIUM_WAIT_TIME = 20


@tag('selenium')
Expand All @@ -81,7 +81,7 @@ def _login(self, name, password):
"""Generic login handler"""
login_url = reverse('auth_login')
self.driver.get(f"{self.live_server_url}{login_url}")
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.NAME, "submit"))
)
user_field = self.driver.find_element(By.NAME, 'username')
Expand All @@ -90,7 +90,7 @@ def _login(self, name, password):
pass_field.send_keys(password)
loginbut = self.driver.find_element(By.NAME, 'submit')
loginbut.click()
WebDriverWait(self.driver, WAIT_TIME).until(
WebDriverWait(self.driver, SELENIUM_WAIT_TIME).until(
expected_conditions.presence_of_element_located((By.CLASS_NAME, "wafer-profile"))
)

Expand Down

0 comments on commit 398bbc4

Please sign in to comment.