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