mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-19 21:09:41 +00:00
Fix crew test
This commit is contained in:
11
.github/workflows/django.yml
vendored
11
.github/workflows/django.yml
vendored
@@ -10,13 +10,6 @@ jobs:
|
||||
build:
|
||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python: [3.9]
|
||||
experimental: [false]
|
||||
include:
|
||||
- python: 3.10.0-alpha.5
|
||||
experimental: true
|
||||
continue-on-error: ${{ matrix.experimental }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -35,7 +28,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
python-version: 3.9
|
||||
- name: Cache python deps
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
@@ -53,7 +46,7 @@ jobs:
|
||||
pipenv run python manage.py makemigrations --check --dry-run
|
||||
pipenv run python manage.py collectstatic --noinput
|
||||
- name: Run Tests
|
||||
run: pipenv run pytest --cov -n auto
|
||||
run: pipenv run pytest -n auto --cov
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: failure()
|
||||
with:
|
||||
|
||||
@@ -279,7 +279,7 @@ class CreateEventChecklist(FormPage):
|
||||
class EditEventChecklist(CreateEventChecklist):
|
||||
URL_TEMPLATE = '/event/checklist/{pk}/edit'
|
||||
_vehicle_row_locator = ('xpath', "//tr[@id[starts-with(., 'vehicle') and not(contains(.,'new'))]]")
|
||||
_crew_row_locator = ('xpath', "//tr[@id[starts-with(., 'crew') and not(contains(. 'new'))]]")
|
||||
_crew_row_locator = ('xpath', "//tr[@id[starts-with(., 'crew') and not(contains(.,'new'))]]")
|
||||
|
||||
@property
|
||||
def vehicles(self):
|
||||
@@ -297,6 +297,32 @@ class EditEventChecklist(CreateEventChecklist):
|
||||
def vehicle(self):
|
||||
return regions.BootstrapSelectElement(self, self.root.find_element(*self._select_locator))
|
||||
|
||||
@property
|
||||
def crew(self):
|
||||
return [self.CrewRow(self, el) for el in self.find_elements(*self._crew_row_locator)]
|
||||
|
||||
class CrewRow(Region):
|
||||
_select_locator = ('xpath', ".//div[contains(@class,'bootstrap-select')]/..")
|
||||
_start_time_locator = ('xpath', ".//input[@name[starts-with(., 'start') and not(contains(.,'new'))]]")
|
||||
_end_time_locator = ('xpath', ".//input[@name[starts-with(., 'end') and not(contains(.,'new'))]]")
|
||||
_role_locator = ('xpath', ".//input[@name[starts-with(., 'role') and not(contains(.,'new'))]]")
|
||||
|
||||
@property
|
||||
def crewmember(self):
|
||||
return regions.BootstrapSelectElement(self, self.root.find_element(*self._select_locator))
|
||||
|
||||
@property
|
||||
def start_time(self):
|
||||
return regions.DateTimePicker(self, self.root.find_element(*self._start_time_locator))
|
||||
|
||||
@property
|
||||
def end_time(self):
|
||||
return regions.DateTimePicker(self, self.root.find_element(*self._end_time_locator))
|
||||
|
||||
@property
|
||||
def role(self):
|
||||
return regions.TextBox(self, self.root.find_element(*self._role_locator))
|
||||
|
||||
@property
|
||||
def success(self):
|
||||
return 'edit' not in self.driver.current_url
|
||||
|
||||
@@ -748,29 +748,27 @@ def test_ec_create_vehicle(logged_in_browser, live_server, admin_user, checklist
|
||||
assert vehicle_name == vehicle.vehicle
|
||||
|
||||
|
||||
# FIXME
|
||||
@pytest.mark.xfail(run=False)
|
||||
# TODO Test validation of end before start
|
||||
def test_ec_create_crew(logged_in_browser, live_server, admin_user, checklist):
|
||||
page = pages.EditEventChecklist(logged_in_browser.driver, live_server.url, pk=checklist.pk).open()
|
||||
page.add_crew()
|
||||
assert len(page.crew) == 1
|
||||
role = "MIC"
|
||||
crew_select = base_regions.BootstrapSelectElement(page, logged_in_browser.find_by_xpath('//tr[@id="crew_-1"]//div[contains(@class, "bootstrap-select")]')[0])
|
||||
start_time = base_regions.DateTimePicker(page, logged_in_browser.find_by_xpath('//*[@name="start_-1"]')[0])
|
||||
end_time = base_regions.DateTimePicker(page, logged_in_browser.find_by_xpath('//*[@name="end_-1"]')[0])
|
||||
|
||||
start_time.set_value(timezone.make_aware(datetime.datetime(2015, 1, 1, 9, 0)))
|
||||
# TODO Test validation of end before start
|
||||
end_time.set_value(timezone.make_aware(datetime.datetime(2015, 1, 1, 10, 30)))
|
||||
crew_select.search(admin_user.name)
|
||||
logged_in_browser.find_by_xpath('//*[@name="role_-1"]').send_keys(role)
|
||||
|
||||
start_time = timezone.make_aware(datetime.datetime(2015, 1, 1, 9, 0))
|
||||
end_time = timezone.make_aware(datetime.datetime(2015, 1, 1, 10, 30))
|
||||
crew = page.crew[0]
|
||||
crew.crewmember.search(admin_user.first_name)
|
||||
crew.role.set_value(role)
|
||||
crew.start_time.set_value(start_time)
|
||||
crew.end_time.set_value(end_time)
|
||||
page.submit()
|
||||
assert page.success
|
||||
checklist.refresh_from_db()
|
||||
|
||||
# Check data is correct
|
||||
crew_obj = models.EventChecklistCrew.objects.get(checklist=checklist.pk)
|
||||
assert admin_user.pk == crew_obj.crewmember.pk
|
||||
assert role == crew_obj.role
|
||||
assert start_time == crew_obj.start
|
||||
assert end_time == crew_obj.end
|
||||
|
||||
|
||||
@screenshot_failure_cls
|
||||
|
||||
Reference in New Issue
Block a user