mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Fix timezone formatting override for CI
Is it a bit hacky? Yes. Does it mean you can't run our test suite outside of Europe? Also yes. Do I care? Not a bit.
This commit is contained in:
@@ -29,7 +29,7 @@ DEBUG = env('DEBUG', cast=bool, default=True)
|
||||
|
||||
STAGING = env('STAGING', cast=bool, default=False)
|
||||
|
||||
CI = env('CI', cast=bool, default=True)
|
||||
CI = env('CI', cast=bool, default=False)
|
||||
|
||||
ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyrigs.herokuapp.com']
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from pypom import Region
|
||||
from django.utils import timezone
|
||||
import PyRIGS.settings
|
||||
from django.conf import settings
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
@@ -20,18 +20,21 @@ def parse_bool_from_string(string):
|
||||
else:
|
||||
return False
|
||||
|
||||
# 12-Hour vs 24-Hour Time. Affects widget display
|
||||
|
||||
|
||||
def get_time_format():
|
||||
# Default
|
||||
time_format = "%H:%M"
|
||||
# If system is 12hr
|
||||
if timezone.now().strftime("%p") or settings.CI:
|
||||
time_format = "%H%M"
|
||||
if settings.CI: # The CI is American
|
||||
time_format = "%I%M%p"
|
||||
return time_format
|
||||
|
||||
|
||||
def get_date_format():
|
||||
date_format = "%d%m%Y"
|
||||
if settings.CI: # And try as I might I can't stop it being so
|
||||
date_format = "%m%d%Y"
|
||||
return date_format
|
||||
|
||||
class BootstrapSelectElement(Region):
|
||||
_main_button_locator = (By.CSS_SELECTOR, 'button.dropdown-toggle')
|
||||
_option_box_locator = (By.CSS_SELECTOR, 'ul.dropdown-menu')
|
||||
@@ -151,13 +154,13 @@ class DatePicker(Region):
|
||||
|
||||
def set_value(self, value):
|
||||
self.root.clear()
|
||||
self.root.send_keys(value.strftime("%d%m%Y"))
|
||||
self.root.send_keys(value.strftime(get_date_format()))
|
||||
|
||||
|
||||
class TimePicker(Region):
|
||||
@property
|
||||
def value(self):
|
||||
return datetime.datetime.strptime(self.root.get_attribute("value"), get_time_format())
|
||||
return datetime.datetime.strptime(self.root.get_attribute("value"), "%H:%M")
|
||||
|
||||
def set_value(self, value):
|
||||
self.root.clear()
|
||||
@@ -167,12 +170,12 @@ class TimePicker(Region):
|
||||
class DateTimePicker(Region):
|
||||
@property
|
||||
def value(self):
|
||||
return datetime.datetime.strptime(self.root.get_attribute("value"), "%Y-%m-%d " + get_time_format())
|
||||
return datetime.datetime.strptime(self.root.get_attribute("value"), "%Y-%m-%d %H:%M")
|
||||
|
||||
def set_value(self, value):
|
||||
self.root.clear()
|
||||
|
||||
date = value.date().strftime("%d%m%Y")
|
||||
date = value.date().strftime(get_date_format())
|
||||
time = value.time().strftime(get_time_format())
|
||||
|
||||
self.root.send_keys(date)
|
||||
|
||||
@@ -136,8 +136,7 @@ class TestAssetForm(AutoLoginTest):
|
||||
self.page.purchased_from_selector.set_option(self.supplier.name, True)
|
||||
self.page.purchase_price = "12.99"
|
||||
self.page.salvage_value = "99.12"
|
||||
acquired = datetime.date(2020, 5, 2)
|
||||
self.page.date_acquired = acquired
|
||||
self.page.date_acquired = acquired = datetime.date(2020, 5, 2)
|
||||
|
||||
self.page.parent_selector.toggle()
|
||||
self.assertTrue(self.page.parent_selector.is_open)
|
||||
|
||||
Reference in New Issue
Block a user