mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Really ought to get a pre-commit hook for pep8...
This commit is contained in:
@@ -234,7 +234,7 @@ class EventManager(models.Manager):
|
||||
(models.Q(dry_hire=True, start_date__gte=timezone.now().date()) & ~models.Q(
|
||||
status=Event.CANCELLED)) | # Active dry hire
|
||||
(models.Q(dry_hire=True, checked_in_by__isnull=True) & (
|
||||
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) | # Active dry hire GT
|
||||
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) | # Active dry hire GT
|
||||
models.Q(status=Event.CANCELLED, start_date__gte=timezone.now().date()) # Canceled but not started
|
||||
).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person',
|
||||
'organisation',
|
||||
@@ -269,7 +269,7 @@ class EventManager(models.Manager):
|
||||
(models.Q(dry_hire=True, start_date__gte=timezone.now().date(), is_rig=True) & ~models.Q(
|
||||
status=Event.CANCELLED)) | # Active dry hire
|
||||
(models.Q(dry_hire=True, checked_in_by__isnull=True, is_rig=True) & (
|
||||
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) # Active dry hire GT
|
||||
models.Q(status=Event.BOOKED) | models.Q(status=Event.CONFIRMED))) # Active dry hire GT
|
||||
).count()
|
||||
return event_count
|
||||
|
||||
@@ -463,9 +463,9 @@ class Event(models.Model, RevisionMixin):
|
||||
hasStartAndEnd = self.has_start_time and self.has_end_time
|
||||
if startEndSameDay and hasStartAndEnd and self.start_time > self.end_time:
|
||||
raise ValidationError('Unless you\'ve invented time travel, the event can\'t finish before it has started.')
|
||||
|
||||
|
||||
if self.access_at is not None:
|
||||
if self.access_at.date() > self.start_date:
|
||||
if self.access_at.date() > self.start_date:
|
||||
raise ValidationError('Regardless of what some clients might think, access time cannot be after the event has started.')
|
||||
elif self.start_time is not None and self.start_date == self.access_at.date() and self.access_at.time() > self.start_time:
|
||||
raise ValidationError('Regardless of what some clients might think, access time cannot be after the event has started.')
|
||||
|
||||
@@ -179,25 +179,25 @@ class GenericList(BasePage):
|
||||
_search_selector = (By.CSS_SELECTOR, 'div.input-group:nth-child(2) > input:nth-child(1)')
|
||||
_search_go_selector = (By.ID, 'id_search')
|
||||
_add_item_selector = (By.CSS_SELECTOR, '.btn-success')
|
||||
|
||||
|
||||
|
||||
|
||||
class UserPage(BasePage):
|
||||
URL_TEMPLATE = 'user/'
|
||||
|
||||
|
||||
_api_key_selector = (By.XPATH, '/html/body/div[1]/div[2]/div[2]/div/div/dl/dd[1]')
|
||||
_cal_url_selector = (By.ID, 'cal-url')
|
||||
_generation_button_selector = (By.LINK_TEXT, 'Generate API Key')
|
||||
|
||||
|
||||
@property
|
||||
def api_key(self):
|
||||
return self.find_element(*self._api_key_selector).text
|
||||
|
||||
|
||||
@property
|
||||
def cal_url(self):
|
||||
return self.find_element(*self._cal_url_selector).text
|
||||
|
||||
def toggle_filter(self, type_name):
|
||||
self.find_element(By.XPATH, "//input[@value='" + type_name + "']").click()
|
||||
|
||||
|
||||
def generate_key(self):
|
||||
self.find_element(*self._generation_button_selector).click()
|
||||
|
||||
@@ -27,7 +27,7 @@ from PyRIGS.tests.base import create_browser, animation_is_finished
|
||||
from django.conf import settings
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
class ClientEventAuthorisationTest(TestCase):
|
||||
auth_data = {
|
||||
|
||||
@@ -204,7 +204,7 @@ class TestEventCreate(BaseRigboardTest):
|
||||
# Should work
|
||||
self.page.submit()
|
||||
self.assertTrue(self.page.success)
|
||||
|
||||
|
||||
def test_access_validation(self):
|
||||
self.select_event_type("Rig")
|
||||
|
||||
@@ -215,19 +215,19 @@ class TestEventCreate(BaseRigboardTest):
|
||||
# TODO This should not be necessary, normally closes automatically
|
||||
self.page.person_selector.toggle()
|
||||
self.assertFalse(self.page.person_selector.is_open)
|
||||
|
||||
|
||||
self.page.name = "Access Validation Test"
|
||||
|
||||
|
||||
self.page.start_date = datetime.date(2020, 1, 1)
|
||||
self.page.access_at = datetime.datetime(2020, 1, 5, 10)
|
||||
|
||||
|
||||
self.page.submit()
|
||||
self.assertFalse(self.page.success)
|
||||
self.assertIn("access time cannot be after the event has started.", self.page.errors["General form errors"][0])
|
||||
|
||||
#Fix it
|
||||
|
||||
# Fix it
|
||||
self.page.access_at = datetime.datetime(2020, 1, 1, 10)
|
||||
|
||||
|
||||
# Should work
|
||||
self.page.submit()
|
||||
self.assertTrue(self.page.success)
|
||||
@@ -517,7 +517,7 @@ class TestCalendar(BaseRigboardTest):
|
||||
self.all_events = set(range(1, 18))
|
||||
self.current_events = (1, 2, 3, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18)
|
||||
self.not_current_events = set(self.all_events) - set(self.current_events)
|
||||
|
||||
|
||||
# produce 7 normal events - 5 current - 1 last week - 1 two years ago - 2 provisional - 2 confirmed - 3 booked
|
||||
models.Event.objects.create(name="TE E1", status=models.Event.PROVISIONAL,
|
||||
start_date=date.today() + timedelta(days=6), description="start future no end")
|
||||
@@ -568,9 +568,9 @@ class TestCalendar(BaseRigboardTest):
|
||||
description="non rig yesterday")
|
||||
models.Event.objects.create(name="TE E18", start_date=date.today(), is_rig=False, status=models.Event.CANCELLED,
|
||||
description="non rig today cancelled")
|
||||
|
||||
|
||||
self.page = pages.UserPage(self.driver, self.live_server_url).open()
|
||||
|
||||
|
||||
def test_api_key_generation(self):
|
||||
# Completes and comes back to /user/
|
||||
# Checks that no api key is displayed
|
||||
@@ -595,10 +595,10 @@ class TestCalendar(BaseRigboardTest):
|
||||
self.page.cal_url)
|
||||
|
||||
# Awesome - all seems to work
|
||||
|
||||
|
||||
def test_ics_files(self):
|
||||
specialEvent = models.Event.objects.get(name="TE E6")
|
||||
|
||||
|
||||
# Now creates an API key, and check a URL is displayed one
|
||||
self.page.generate_key()
|
||||
|
||||
@@ -633,11 +633,11 @@ class TestCalendar(BaseRigboardTest):
|
||||
# Only non rigs
|
||||
self.page.toggle_filter('rig')
|
||||
self.page.toggle_filter('non-rig')
|
||||
|
||||
|
||||
icalUrl = self.page.cal_url
|
||||
response = c.get(icalUrl)
|
||||
self.assertEqual(200, response.status_code)
|
||||
|
||||
|
||||
expectedIn = [10, 11, 12, 13]
|
||||
for test in range(1, 18):
|
||||
if test in expectedIn:
|
||||
|
||||
Reference in New Issue
Block a user