Really ought to get a pre-commit hook for pep8...

This commit is contained in:
2020-05-25 13:40:53 +01:00
parent 18fde7c16a
commit 2f7389d8bb
4 changed files with 25 additions and 25 deletions

View File

@@ -234,7 +234,7 @@ class EventManager(models.Manager):
(models.Q(dry_hire=True, start_date__gte=timezone.now().date()) & ~models.Q( (models.Q(dry_hire=True, start_date__gte=timezone.now().date()) & ~models.Q(
status=Event.CANCELLED)) | # Active dry hire status=Event.CANCELLED)) | # Active dry hire
(models.Q(dry_hire=True, checked_in_by__isnull=True) & ( (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 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', ).order_by('start_date', 'end_date', 'start_time', 'end_time', 'meet_at').select_related('person',
'organisation', '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( (models.Q(dry_hire=True, start_date__gte=timezone.now().date(), is_rig=True) & ~models.Q(
status=Event.CANCELLED)) | # Active dry hire status=Event.CANCELLED)) | # Active dry hire
(models.Q(dry_hire=True, checked_in_by__isnull=True, is_rig=True) & ( (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() ).count()
return event_count return event_count
@@ -463,9 +463,9 @@ class Event(models.Model, RevisionMixin):
hasStartAndEnd = self.has_start_time and self.has_end_time hasStartAndEnd = self.has_start_time and self.has_end_time
if startEndSameDay and hasStartAndEnd and self.start_time > self.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.') 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 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.') 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: 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.') raise ValidationError('Regardless of what some clients might think, access time cannot be after the event has started.')

View File

@@ -179,25 +179,25 @@ class GenericList(BasePage):
_search_selector = (By.CSS_SELECTOR, 'div.input-group:nth-child(2) > input:nth-child(1)') _search_selector = (By.CSS_SELECTOR, 'div.input-group:nth-child(2) > input:nth-child(1)')
_search_go_selector = (By.ID, 'id_search') _search_go_selector = (By.ID, 'id_search')
_add_item_selector = (By.CSS_SELECTOR, '.btn-success') _add_item_selector = (By.CSS_SELECTOR, '.btn-success')
class UserPage(BasePage): class UserPage(BasePage):
URL_TEMPLATE = 'user/' URL_TEMPLATE = 'user/'
_api_key_selector = (By.XPATH, '/html/body/div[1]/div[2]/div[2]/div/div/dl/dd[1]') _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') _cal_url_selector = (By.ID, 'cal-url')
_generation_button_selector = (By.LINK_TEXT, 'Generate API Key') _generation_button_selector = (By.LINK_TEXT, 'Generate API Key')
@property @property
def api_key(self): def api_key(self):
return self.find_element(*self._api_key_selector).text return self.find_element(*self._api_key_selector).text
@property @property
def cal_url(self): def cal_url(self):
return self.find_element(*self._cal_url_selector).text return self.find_element(*self._cal_url_selector).text
def toggle_filter(self, type_name): def toggle_filter(self, type_name):
self.find_element(By.XPATH, "//input[@value='" + type_name + "']").click() self.find_element(By.XPATH, "//input[@value='" + type_name + "']").click()
def generate_key(self): def generate_key(self):
self.find_element(*self._generation_button_selector).click() self.find_element(*self._generation_button_selector).click()

View File

@@ -27,7 +27,7 @@ from PyRIGS.tests.base import create_browser, animation_is_finished
from django.conf import settings from django.conf import settings
import sys import sys
class ClientEventAuthorisationTest(TestCase): class ClientEventAuthorisationTest(TestCase):
auth_data = { auth_data = {

View File

@@ -204,7 +204,7 @@ class TestEventCreate(BaseRigboardTest):
# Should work # Should work
self.page.submit() self.page.submit()
self.assertTrue(self.page.success) self.assertTrue(self.page.success)
def test_access_validation(self): def test_access_validation(self):
self.select_event_type("Rig") self.select_event_type("Rig")
@@ -215,19 +215,19 @@ class TestEventCreate(BaseRigboardTest):
# TODO This should not be necessary, normally closes automatically # TODO This should not be necessary, normally closes automatically
self.page.person_selector.toggle() self.page.person_selector.toggle()
self.assertFalse(self.page.person_selector.is_open) self.assertFalse(self.page.person_selector.is_open)
self.page.name = "Access Validation Test" self.page.name = "Access Validation Test"
self.page.start_date = datetime.date(2020, 1, 1) self.page.start_date = datetime.date(2020, 1, 1)
self.page.access_at = datetime.datetime(2020, 1, 5, 10) self.page.access_at = datetime.datetime(2020, 1, 5, 10)
self.page.submit() self.page.submit()
self.assertFalse(self.page.success) self.assertFalse(self.page.success)
self.assertIn("access time cannot be after the event has started.", self.page.errors["General form errors"][0]) 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) self.page.access_at = datetime.datetime(2020, 1, 1, 10)
# Should work # Should work
self.page.submit() self.page.submit()
self.assertTrue(self.page.success) self.assertTrue(self.page.success)
@@ -517,7 +517,7 @@ class TestCalendar(BaseRigboardTest):
self.all_events = set(range(1, 18)) self.all_events = set(range(1, 18))
self.current_events = (1, 2, 3, 6, 7, 8, 10, 11, 12, 14, 15, 16, 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) 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 # 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, models.Event.objects.create(name="TE E1", status=models.Event.PROVISIONAL,
start_date=date.today() + timedelta(days=6), description="start future no end") start_date=date.today() + timedelta(days=6), description="start future no end")
@@ -568,9 +568,9 @@ class TestCalendar(BaseRigboardTest):
description="non rig yesterday") description="non rig yesterday")
models.Event.objects.create(name="TE E18", start_date=date.today(), is_rig=False, status=models.Event.CANCELLED, models.Event.objects.create(name="TE E18", start_date=date.today(), is_rig=False, status=models.Event.CANCELLED,
description="non rig today cancelled") description="non rig today cancelled")
self.page = pages.UserPage(self.driver, self.live_server_url).open() self.page = pages.UserPage(self.driver, self.live_server_url).open()
def test_api_key_generation(self): def test_api_key_generation(self):
# Completes and comes back to /user/ # Completes and comes back to /user/
# Checks that no api key is displayed # Checks that no api key is displayed
@@ -595,10 +595,10 @@ class TestCalendar(BaseRigboardTest):
self.page.cal_url) self.page.cal_url)
# Awesome - all seems to work # Awesome - all seems to work
def test_ics_files(self): def test_ics_files(self):
specialEvent = models.Event.objects.get(name="TE E6") specialEvent = models.Event.objects.get(name="TE E6")
# Now creates an API key, and check a URL is displayed one # Now creates an API key, and check a URL is displayed one
self.page.generate_key() self.page.generate_key()
@@ -633,11 +633,11 @@ class TestCalendar(BaseRigboardTest):
# Only non rigs # Only non rigs
self.page.toggle_filter('rig') self.page.toggle_filter('rig')
self.page.toggle_filter('non-rig') self.page.toggle_filter('non-rig')
icalUrl = self.page.cal_url icalUrl = self.page.cal_url
response = c.get(icalUrl) response = c.get(icalUrl)
self.assertEqual(200, response.status_code) self.assertEqual(200, response.status_code)
expectedIn = [10, 11, 12, 13] expectedIn = [10, 11, 12, 13]
for test in range(1, 18): for test in range(1, 18):
if test in expectedIn: if test in expectedIn: