mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-26 09:52:16 +00:00
pep8
This commit is contained in:
@@ -7,9 +7,11 @@ import pytz
|
|||||||
from datetime import date, time, datetime, timedelta
|
from datetime import date, time, datetime, timedelta
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
def create_datetime(year, month, day, hour, min):
|
def create_datetime(year, month, day, hour, min):
|
||||||
tz = pytz.timezone(settings.TIME_ZONE)
|
tz = pytz.timezone(settings.TIME_ZONE)
|
||||||
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)
|
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)
|
||||||
|
|
||||||
|
|
||||||
def create_browser():
|
def create_browser():
|
||||||
options = webdriver.ChromeOptions()
|
options = webdriver.ChromeOptions()
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ class DateTimePicker(Region):
|
|||||||
self.root.send_keys(Keys.TAB)
|
self.root.send_keys(Keys.TAB)
|
||||||
self.root.send_keys(time)
|
self.root.send_keys(time)
|
||||||
|
|
||||||
|
|
||||||
class SingleSelectPicker(Region):
|
class SingleSelectPicker(Region):
|
||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ from django.views.decorators.clickjacking import xframe_options_exempt
|
|||||||
from django.contrib.auth.views import LoginView
|
from django.contrib.auth.views import LoginView
|
||||||
from registration.backends.default.views import RegistrationView
|
from registration.backends.default.views import RegistrationView
|
||||||
from PyRIGS.decorators import permission_required_with_403
|
from PyRIGS.decorators import permission_required_with_403
|
||||||
import RIGS, users
|
import RIGS
|
||||||
|
import users
|
||||||
from PyRIGS import views
|
from PyRIGS import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class InvoicePrint(generic.View):
|
|||||||
|
|
||||||
response = HttpResponse(content_type='application/pdf')
|
response = HttpResponse(content_type='application/pdf')
|
||||||
response['Content-Disposition'] = "filename=Invoice %05d - N%05d | %s.pdf" % (
|
response['Content-Disposition'] = "filename=Invoice %05d - N%05d | %s.pdf" % (
|
||||||
invoice.pk, invoice.event.pk, escapedEventName)
|
invoice.pk, invoice.event.pk, escapedEventName)
|
||||||
response.write(pdfData)
|
response.write(pdfData)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -176,8 +176,8 @@ class InvoiceWaiting(generic.ListView):
|
|||||||
# @todo find a way to select items
|
# @todo find a way to select items
|
||||||
events = self.model.objects.filter(
|
events = self.model.objects.filter(
|
||||||
(
|
(
|
||||||
Q(start_date__lte=datetime.date.today(), end_date__isnull=True) | # Starts before with no end
|
Q(start_date__lte=datetime.date.today(), end_date__isnull=True) | # Starts before with no end
|
||||||
Q(end_date__lte=datetime.date.today()) # Has end date, finishes before
|
Q(end_date__lte=datetime.date.today()) # Has end date, finishes before
|
||||||
) & Q(invoice__isnull=True) & # Has not already been invoiced
|
) & Q(invoice__isnull=True) & # Has not already been invoiced
|
||||||
Q(is_rig=True) # Is a rig (not non-rig)
|
Q(is_rig=True) # Is a rig (not non-rig)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from PyRIGS.tests.pages import BasePage, FormPage
|
|||||||
from selenium.common.exceptions import NoSuchElementException
|
from selenium.common.exceptions import NoSuchElementException
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
|
||||||
|
|
||||||
class Index(BasePage):
|
class Index(BasePage):
|
||||||
URL_TEMPLATE = reverse('index')
|
URL_TEMPLATE = reverse('index')
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@ class EventDetail(BasePage):
|
|||||||
def phone(self):
|
def phone(self):
|
||||||
return self.find_element(*self._person_panel_selector).find_element(*self._phone_selector).text
|
return self.find_element(*self._person_panel_selector).find_element(*self._phone_selector).text
|
||||||
|
|
||||||
|
|
||||||
class CreateEvent(FormPage):
|
class CreateEvent(FormPage):
|
||||||
URL_TEMPLATE = reverse('event_create')
|
URL_TEMPLATE = reverse('event_create')
|
||||||
|
|
||||||
@@ -154,6 +156,7 @@ class CreateEvent(FormPage):
|
|||||||
def success(self):
|
def success(self):
|
||||||
return '/create' not in self.driver.current_url
|
return '/create' not in self.driver.current_url
|
||||||
|
|
||||||
|
|
||||||
class DuplicateEvent(CreateEvent):
|
class DuplicateEvent(CreateEvent):
|
||||||
URL_TEMPLATE = 'event/{event_id}/duplicate'
|
URL_TEMPLATE = 'event/{event_id}/duplicate'
|
||||||
_submit_locator = (By.XPATH, '/html/body/div[1]/form/div/div[5]/div/button')
|
_submit_locator = (By.XPATH, '/html/body/div[1]/form/div/div[5]/div/button')
|
||||||
@@ -162,6 +165,7 @@ class DuplicateEvent(CreateEvent):
|
|||||||
def success(self):
|
def success(self):
|
||||||
return '/duplicate' not in self.driver.current_url
|
return '/duplicate' not in self.driver.current_url
|
||||||
|
|
||||||
|
|
||||||
class EditEvent(CreateEvent):
|
class EditEvent(CreateEvent):
|
||||||
URL_TEMPLATE = 'event/{event_id}/edit'
|
URL_TEMPLATE = 'event/{event_id}/edit'
|
||||||
_submit_locator = (By.XPATH, '/html/body/div[1]/form/div/div[5]/div/button')
|
_submit_locator = (By.XPATH, '/html/body/div[1]/form/div/div[5]/div/button')
|
||||||
@@ -170,8 +174,8 @@ class EditEvent(CreateEvent):
|
|||||||
def success(self):
|
def success(self):
|
||||||
return '/edit' not in self.driver.current_url
|
return '/edit' not in self.driver.current_url
|
||||||
|
|
||||||
|
|
||||||
class GenericList(BasePage):
|
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')
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from django.conf import settings
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class IcalTest(LiveServerTestCase):
|
class IcalTest(LiveServerTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.all_events = set(range(1, 18))
|
self.all_events = set(range(1, 18))
|
||||||
@@ -415,6 +416,7 @@ class TECEventAuthorisationTest(TestCase):
|
|||||||
self.assertEqual(self.event.auth_request_to, 'client@functional.test')
|
self.assertEqual(self.event.auth_request_to, 'client@functional.test')
|
||||||
self.assertIsNotNone(self.event.auth_request_at)
|
self.assertIsNotNone(self.event.auth_request_at)
|
||||||
|
|
||||||
|
|
||||||
class SearchTest(LiveServerTestCase):
|
class SearchTest(LiveServerTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.profile = models.Profile(
|
self.profile = models.Profile(
|
||||||
|
|||||||
@@ -20,19 +20,20 @@ from django.utils import timezone
|
|||||||
from selenium.webdriver.common.action_chains import ActionChains
|
from selenium.webdriver.common.action_chains import ActionChains
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
||||||
|
|
||||||
class BaseRigboardTest(AutoLoginTest):
|
class BaseRigboardTest(AutoLoginTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05', rate=0.20, comment='test1')
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.client = models.Person.objects.create(name='Rigboard Test Person', email='rigboard@functional.test')
|
self.client = models.Person.objects.create(name='Rigboard Test Person', email='rigboard@functional.test')
|
||||||
self.testEvent = models.Event.objects.create(name="TE E1", status=models.Event.PROVISIONAL,
|
self.testEvent = models.Event.objects.create(name="TE E1", status=models.Event.PROVISIONAL,
|
||||||
start_date=date.today() + timedelta(days=6),
|
start_date=date.today() + timedelta(days=6),
|
||||||
description="start future no end",
|
description="start future no end",
|
||||||
purchase_order='TESTPO',
|
purchase_order='TESTPO',
|
||||||
person=self.client,
|
person=self.client,
|
||||||
auth_request_by=self.profile,
|
auth_request_by=self.profile,
|
||||||
auth_request_at=base.create_datetime(2015, 0o6, 0o4, 10, 00),
|
auth_request_at=base.create_datetime(2015, 0o6, 0o4, 10, 00),
|
||||||
auth_request_to="some@email.address")
|
auth_request_to="some@email.address")
|
||||||
|
|
||||||
item1 = models.EventItem(
|
item1 = models.EventItem(
|
||||||
event=self.testEvent,
|
event=self.testEvent,
|
||||||
@@ -58,17 +59,18 @@ class BaseRigboardTest(AutoLoginTest):
|
|||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
self.assertTrue(self.page.is_expanded)
|
self.assertTrue(self.page.is_expanded)
|
||||||
|
|
||||||
|
|
||||||
class TestRigboard(BaseRigboardTest):
|
class TestRigboard(BaseRigboardTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.testEvent2 = models.Event.objects.create(name="TE E2", status=models.Event.PROVISIONAL,
|
self.testEvent2 = models.Event.objects.create(name="TE E2", status=models.Event.PROVISIONAL,
|
||||||
start_date=date.today() + timedelta(days=8),
|
start_date=date.today() + timedelta(days=8),
|
||||||
description="start future no end, later",
|
description="start future no end, later",
|
||||||
purchase_order='TESTPO',
|
purchase_order='TESTPO',
|
||||||
person=self.client,
|
person=self.client,
|
||||||
auth_request_by=self.profile,
|
auth_request_by=self.profile,
|
||||||
auth_request_at=base.create_datetime(2015, 0o6, 0o4, 10, 00),
|
auth_request_at=base.create_datetime(2015, 0o6, 0o4, 10, 00),
|
||||||
auth_request_to="some@email.address")
|
auth_request_to="some@email.address")
|
||||||
self.page = pages.Rigboard(self.driver, self.live_server_url).open()
|
self.page = pages.Rigboard(self.driver, self.live_server_url).open()
|
||||||
|
|
||||||
def test_buttons(self):
|
def test_buttons(self):
|
||||||
@@ -185,7 +187,7 @@ class TestEventCreate(BaseRigboardTest):
|
|||||||
self.assertIn("can't finish before it has started", self.page.errors["General form errors"][0])
|
self.assertIn("can't finish before it has started", self.page.errors["General form errors"][0])
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(animation_is_finished())
|
||||||
|
|
||||||
#end time before start
|
# end time before start
|
||||||
self.page.start_date = datetime.date(2020, 1, 1)
|
self.page.start_date = datetime.date(2020, 1, 1)
|
||||||
self.page.start_time = datetime.time(10)
|
self.page.start_time = datetime.time(10)
|
||||||
self.page.end_time = datetime.time(9)
|
self.page.end_time = datetime.time(9)
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ class ActivityTable(versioning.ActivityTable):
|
|||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class CableTypeList(generic.ListView):
|
class CableTypeList(generic.ListView):
|
||||||
model = models.CableType
|
model = models.CableType
|
||||||
template_name = 'cable_type_list.html'
|
template_name = 'cable_type_list.html'
|
||||||
|
|||||||
@@ -185,4 +185,3 @@ class UserRegistrationTest(LiveServerTestCase):
|
|||||||
self.assertEqual(profileObject.email, 'test@example.com')
|
self.assertEqual(profileObject.email, 'test@example.com')
|
||||||
|
|
||||||
# All is well
|
# All is well
|
||||||
|
|
||||||
|
|||||||
@@ -194,6 +194,8 @@ class RIGSVersionTestCase(TestCase):
|
|||||||
self.assertTrue(diffs[0].new is None)
|
self.assertTrue(diffs[0].new is None)
|
||||||
|
|
||||||
# Unit Tests
|
# Unit Tests
|
||||||
|
|
||||||
|
|
||||||
class TestVersioningViews(TestCase):
|
class TestVersioningViews(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
@@ -273,5 +275,4 @@ class TestVersioningViews(TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
|
||||||
#Functional Tests
|
# Functional Tests
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user