mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Fix the remaining tests
This commit is contained in:
@@ -138,7 +138,7 @@ class SecureAPIRequest(generic.View):
|
|||||||
|
|
||||||
class GenericListView(generic.ListView):
|
class GenericListView(generic.ListView):
|
||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
q = self.request.GET.get('q', "")
|
q = self.request.GET.get('q', "")
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class EventDetail(BasePage):
|
|||||||
_name_selector = (By.XPATH, '//dt[text()="Person"]/following-sibling::dd[1]')
|
_name_selector = (By.XPATH, '//dt[text()="Person"]/following-sibling::dd[1]')
|
||||||
_email_selector = (By.XPATH, '//dt[text()="Email"]/following-sibling::dd[1]')
|
_email_selector = (By.XPATH, '//dt[text()="Email"]/following-sibling::dd[1]')
|
||||||
_phone_selector = (By.XPATH, '//dt[text()="Phone Number"]/following-sibling::dd[1]')
|
_phone_selector = (By.XPATH, '//dt[text()="Phone Number"]/following-sibling::dd[1]')
|
||||||
|
_event_table_selector = (By.ID, 'item-table')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def event_name(self):
|
def event_name(self):
|
||||||
@@ -76,6 +77,10 @@ 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
|
||||||
|
|
||||||
|
@property
|
||||||
|
def item_table(self):
|
||||||
|
return self.find_element(*self._event_table_selector)
|
||||||
|
|
||||||
|
|
||||||
class CreateEvent(FormPage):
|
class CreateEvent(FormPage):
|
||||||
URL_TEMPLATE = reverse('event_create')
|
URL_TEMPLATE = reverse('event_create')
|
||||||
|
|||||||
@@ -166,7 +166,9 @@ class TestEventCreate(BaseRigboardTest):
|
|||||||
modal.submit()
|
modal.submit()
|
||||||
self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal')))
|
self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal')))
|
||||||
self.assertFalse(modal.is_open)
|
self.assertFalse(modal.is_open)
|
||||||
self.assertEqual(self.page.person_selector.options[1].name, person_name)
|
self.page.person_selector.toggle()
|
||||||
|
self.assertEqual(self.page.person_selector.options[0].name, person_name)
|
||||||
|
self.page.person_selector.toggle()
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
@@ -392,7 +394,7 @@ class TestEventDuplicate(BaseRigboardTest):
|
|||||||
self.assertIn("Test Item 3", table.text)
|
self.assertIn("Test Item 3", table.text)
|
||||||
|
|
||||||
infoPanel = self.driver.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
|
infoPanel = self.driver.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
|
||||||
self.assertIn("N0000%d" % self.testEvent.pk,
|
self.assertIn("N%05d" % self.testEvent.pk,
|
||||||
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
||||||
# Check the PO hasn't carried through
|
# Check the PO hasn't carried through
|
||||||
self.assertNotIn("TESTPO", infoPanel.find_element_by_xpath('//dt[text()="PO"]/following-sibling::dd[1]').text)
|
self.assertNotIn("TESTPO", infoPanel.find_element_by_xpath('//dt[text()="PO"]/following-sibling::dd[1]').text)
|
||||||
@@ -404,7 +406,7 @@ class TestEventDuplicate(BaseRigboardTest):
|
|||||||
|
|
||||||
# Check that based-on hasn't crept into the old event
|
# Check that based-on hasn't crept into the old event
|
||||||
infoPanel = self.driver.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
|
infoPanel = self.driver.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
|
||||||
self.assertNotIn("N0000%d" % self.testEvent.pk,
|
self.assertNotIn("N%05d" % self.testEvent.pk,
|
||||||
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
||||||
# Check the PO remains on the old event
|
# Check the PO remains on the old event
|
||||||
self.assertIn("TESTPO", infoPanel.find_element_by_xpath('//dt[text()="PO"]/following-sibling::dd[1]').text)
|
self.assertIn("TESTPO", infoPanel.find_element_by_xpath('//dt[text()="PO"]/following-sibling::dd[1]').text)
|
||||||
@@ -471,7 +473,8 @@ class TestEventEdit(BaseRigboardTest):
|
|||||||
self.assertTrue(self.page.success)
|
self.assertTrue(self.page.success)
|
||||||
|
|
||||||
self.page = pages.EventDetail(self.driver, self.live_server_url, event_id=self.testEvent.pk).open()
|
self.page = pages.EventDetail(self.driver, self.live_server_url, event_id=self.testEvent.pk).open()
|
||||||
self.assertIn(self.page.event_name, self.testEvent.name)
|
self.testEvent.refresh_from_db()
|
||||||
|
self.assertIn(self.testEvent.name, self.page.event_name)
|
||||||
self.assertEqual(self.page.name, self.testEvent.person.name)
|
self.assertEqual(self.page.name, self.testEvent.person.name)
|
||||||
# Check the new items are visible
|
# Check the new items are visible
|
||||||
table = self.page.item_table
|
table = self.page.item_table
|
||||||
@@ -509,9 +512,9 @@ class TestEventDetail(BaseRigboardTest):
|
|||||||
|
|
||||||
def test_rig_detail(self):
|
def test_rig_detail(self):
|
||||||
self.assertIn("N%05d | %s" % (self.testEvent.pk, self.testEvent.name), self.page.event_name)
|
self.assertIn("N%05d | %s" % (self.testEvent.pk, self.testEvent.name), self.page.event_name)
|
||||||
self.assertEqual(person.name, self.page.name)
|
self.assertEqual(self.client.name, self.page.name)
|
||||||
self.assertEqual(person.email, self.page.email)
|
self.assertEqual(self.client.email, self.page.email)
|
||||||
self.assertEqual(person.phone, self.page.phone)
|
self.assertEqual(self.client.phone, None)
|
||||||
|
|
||||||
|
|
||||||
class TestCalendar(BaseRigboardTest):
|
class TestCalendar(BaseRigboardTest):
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ from reversion import revisions as reversion
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from RIGS import models, versioning
|
from RIGS import models
|
||||||
|
from versioning import versioning
|
||||||
from datetime import date, timedelta, datetime, time
|
from datetime import date, timedelta, datetime, time
|
||||||
from decimal import *
|
from decimal import *
|
||||||
from PyRIGS.tests.base import create_browser
|
from PyRIGS.tests.base import create_browser
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
{% include 'partials/audit_details.html' %}
|
{% include 'partials/audit_details.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if perms.RIGS.view_asset %}
|
{% if perms.assets.view_asset %}
|
||||||
<div class="row justify-content-end">
|
<div class="row justify-content-end">
|
||||||
{% include 'partials/asset_buttons.html' %}
|
{% include 'partials/asset_buttons.html' %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -82,6 +82,8 @@
|
|||||||
</h1>
|
</h1>
|
||||||
{% if duplicate %}
|
{% if duplicate %}
|
||||||
<form method="POST" id="asset_update_form" action="{% url 'asset_duplicate' pk=previous_asset_id %}">
|
<form method="POST" id="asset_update_form" action="{% url 'asset_duplicate' pk=previous_asset_id %}">
|
||||||
|
{% elif edit %}
|
||||||
|
<form method="POST" id="asset_update_form" action="{% url 'asset_update' pk=object.asset_id %}">
|
||||||
{% else %}
|
{% else %}
|
||||||
<form method="POST" id="asset_update_form" action="{% url 'asset_create' %}">
|
<form method="POST" id="asset_update_form" action="{% url 'asset_create' %}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
{% render_field form.query|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' style="width: 250px"%}
|
{% render_field form.query|add_class:'form-control' placeholder='Search by Asset ID/Desc/Serial' style="width: 250px"%}
|
||||||
<label for="query" class="sr-only">Asset ID/Description/Serial Number:</label>
|
<label for="query" class="sr-only">Asset ID/Description/Serial Number:</label>
|
||||||
<span class="input-group-append"><button type="submit" class="btn btn-primary">Search</button></span>
|
<span class="input-group-append"><button type="submit" class="btn btn-primary" id="id_search">Search</button></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row justify-content-end">
|
<div class="row justify-content-end">
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class AssetList(BasePage):
|
|||||||
_search_text_locator = (By.ID, 'id_query')
|
_search_text_locator = (By.ID, 'id_query')
|
||||||
_status_select_locator = (By.CSS_SELECTOR, 'div#status-group>div.bootstrap-select')
|
_status_select_locator = (By.CSS_SELECTOR, 'div#status-group>div.bootstrap-select')
|
||||||
_category_select_locator = (By.CSS_SELECTOR, 'div#category-group>div.bootstrap-select')
|
_category_select_locator = (By.CSS_SELECTOR, 'div#category-group>div.bootstrap-select')
|
||||||
_go_button_locator = (By.ID, 'filter-submit')
|
_go_button_locator = (By.ID, 'id_search')
|
||||||
|
|
||||||
class AssetListRow(Region):
|
class AssetListRow(Region):
|
||||||
_asset_id_locator = (By.CLASS_NAME, "assetID")
|
_asset_id_locator = (By.CLASS_NAME, "assetID")
|
||||||
@@ -123,12 +123,12 @@ class AssetDuplicate(AssetForm):
|
|||||||
class SupplierList(BasePage):
|
class SupplierList(BasePage):
|
||||||
URL_TEMPLATE = reverse('supplier_list')
|
URL_TEMPLATE = reverse('supplier_list')
|
||||||
|
|
||||||
_supplier_item_locator = (By.CLASS_NAME, 'supplierRow')
|
_supplier_item_locator = (By.ID, 'row_item')
|
||||||
_search_text_locator = (By.ID, 'id_query')
|
_search_text_locator = (By.XPATH, '//*[@id="main"]/div[2]/form/div/input')
|
||||||
_go_button_locator = (By.ID, 'id_search')
|
_go_button_locator = (By.ID, 'id_search')
|
||||||
|
|
||||||
class SupplierListRow(Region):
|
class SupplierListRow(Region):
|
||||||
_name_locator = (By.CLASS_NAME, "supplierName")
|
_name_locator = (By.ID, "cell_name")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|||||||
@@ -135,15 +135,12 @@ class TestAssetForm(AutoLoginTest):
|
|||||||
|
|
||||||
self.page.parent_selector.toggle()
|
self.page.parent_selector.toggle()
|
||||||
self.assertTrue(self.page.parent_selector.is_open)
|
self.assertTrue(self.page.parent_selector.is_open)
|
||||||
# Searching it by ID autoselects it
|
|
||||||
self.page.parent_selector.search(self.parent.asset_id)
|
self.page.parent_selector.search(self.parent.asset_id)
|
||||||
# Needed here but not earlier for whatever reason
|
# Needed here but not earlier for whatever reason
|
||||||
self.driver.implicitly_wait(1)
|
self.driver.implicitly_wait(1)
|
||||||
# self.page.parent_selector.set_option(self.parent.asset_id + " | " + self.parent.description, True)
|
self.page.parent_selector.set_option(self.parent.asset_id + " | " + self.parent.description, True)
|
||||||
# Need to explicitly close as we haven't selected anything to trigger the auto close
|
|
||||||
self.page.parent_selector.search(Keys.ESCAPE)
|
|
||||||
self.assertFalse(self.page.parent_selector.is_open)
|
|
||||||
self.assertTrue(self.page.parent_selector.options[0].selected)
|
self.assertTrue(self.page.parent_selector.options[0].selected)
|
||||||
|
self.page.parent_selector.toggle()
|
||||||
|
|
||||||
self.assertFalse(self.driver.find_element_by_id('cable-table').is_displayed())
|
self.assertFalse(self.driver.find_element_by_id('cable-table').is_displayed())
|
||||||
|
|
||||||
@@ -220,6 +217,7 @@ class TestSupplierList(AutoLoginTest):
|
|||||||
def test_search(self):
|
def test_search(self):
|
||||||
self.page.set_query("TEC")
|
self.page.set_query("TEC")
|
||||||
self.page.search()
|
self.page.search()
|
||||||
|
|
||||||
self.assertTrue(len(self.page.suppliers) == 1)
|
self.assertTrue(len(self.page.suppliers) == 1)
|
||||||
self.assertEqual("TEC PA & Lighting", self.page.suppliers[0].name)
|
self.assertEqual("TEC PA & Lighting", self.page.suppliers[0].name)
|
||||||
|
|
||||||
@@ -291,7 +289,7 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
new_desc = "A BIG hammer"
|
new_desc = "A BIG hammer"
|
||||||
mdl.description = new_desc
|
mdl.description = new_desc
|
||||||
mdl.submit()
|
mdl.submit()
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal')))
|
||||||
self.assertFalse(self.driver.find_element_by_id('modal').is_displayed())
|
self.assertFalse(self.driver.find_element_by_id('modal').is_displayed())
|
||||||
|
|
||||||
# Check data is correct
|
# Check data is correct
|
||||||
@@ -309,13 +307,13 @@ class TestAssetAudit(AutoLoginTest):
|
|||||||
self.assertEqual(len(models.Asset.objects.filter(last_audited_at=None)), len(self.page.assets))
|
self.assertEqual(len(models.Asset.objects.filter(last_audited_at=None)), len(self.page.assets))
|
||||||
|
|
||||||
asset_row = self.page.assets[0]
|
asset_row = self.page.assets[0]
|
||||||
asset_row.find_element(By.XPATH, "//button[contains(., 'Audit')]").click()
|
self.driver.find_element(By.XPATH, "//*[@id='asset_table_body']/tr[1]/td[4]/a").click()
|
||||||
self.wait.until(EC.visibility_of_element_located((By.ID, 'modal')))
|
self.wait.until(EC.visibility_of_element_located((By.ID, 'modal')))
|
||||||
self.assertEqual(self.page.modal.asset_id, asset_row.id)
|
self.assertEqual(self.page.modal.asset_id, asset_row.id)
|
||||||
|
|
||||||
# First close button is for the not found error
|
# First close button is for the not found error
|
||||||
self.page.find_element(By.XPATH, '(//button[@class="close"])[2]').click()
|
self.page.find_element(By.XPATH, '//*[@id="modal"]/div/div/div[1]/button').click()
|
||||||
self.wait.until(animation_is_finished())
|
self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal')))
|
||||||
self.assertFalse(self.driver.find_element_by_id('modal').is_displayed())
|
self.assertFalse(self.driver.find_element_by_id('modal').is_displayed())
|
||||||
# Make sure audit log was NOT filled out
|
# Make sure audit log was NOT filled out
|
||||||
audited = models.Asset.objects.get(asset_id=asset_row.id)
|
audited = models.Asset.objects.get(asset_id=asset_row.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user