mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Initial port of duplicate testing
Needs the latter half rewriting once we have an EventDetail POM
This commit is contained in:
@@ -64,115 +64,6 @@ class EventTest(LiveServerTestCase):
|
||||
|
||||
self.assertEqual(self.live_server_url + n, self.browser.current_url)
|
||||
|
||||
def testEventDuplicate(self):
|
||||
client = models.Person.objects.create(name='Duplicate Test Person', email='duplicate@functional.test')
|
||||
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=client,
|
||||
auth_request_by=self.profile,
|
||||
auth_request_at=self.create_datetime(2015, 0o6, 0o4, 10, 00),
|
||||
auth_request_to="some@email.address")
|
||||
|
||||
item1 = models.EventItem(
|
||||
event=testEvent,
|
||||
name="Test Item 1",
|
||||
cost="10.00",
|
||||
quantity="1",
|
||||
order=1
|
||||
).save()
|
||||
item2 = models.EventItem(
|
||||
event=testEvent,
|
||||
name="Test Item 2",
|
||||
description="Foo",
|
||||
cost="9.72",
|
||||
quantity="3",
|
||||
order=2,
|
||||
).save()
|
||||
|
||||
self.browser.get(self.live_server_url + '/event/' + str(testEvent.pk) + '/duplicate/')
|
||||
self.authenticate('/event/' + str(testEvent.pk) + '/duplicate/')
|
||||
|
||||
wait = WebDriverWait(self.browser, 3) # setup WebDriverWait to use later (to wait for animations)
|
||||
|
||||
save = self.browser.find_element_by_xpath(
|
||||
'(//button[@type="submit"])[3]')
|
||||
form = self.browser.find_element_by_xpath('/html/body/div[2]/div[1]/form')
|
||||
|
||||
# Check the items are visible
|
||||
table = self.browser.find_element_by_id('item-table') # ID number is known, see above
|
||||
self.assertIn("Test Item 1", table.text)
|
||||
self.assertIn("Test Item 2", table.text)
|
||||
|
||||
# Check the info message is visible
|
||||
self.assertIn("Event data duplicated but not yet saved", self.browser.find_element_by_id('content').text)
|
||||
|
||||
# Add item
|
||||
form.find_element_by_xpath('//button[contains(@class, "item-add")]').click()
|
||||
modal = self.browser.find_element_by_id("itemModal")
|
||||
wait.until(animation_is_finished())
|
||||
# See modal has opened
|
||||
self.assertTrue(modal.is_displayed())
|
||||
modal.find_element_by_id("item_name").send_keys("Test Item 3")
|
||||
modal.find_element_by_id("item_description").send_keys(
|
||||
"This is an item description\nthat for reasons unknown spans two lines")
|
||||
e = modal.find_element_by_id("item_quantity")
|
||||
e.click()
|
||||
e.send_keys(Keys.UP)
|
||||
e.send_keys(Keys.UP)
|
||||
e = modal.find_element_by_id("item_cost")
|
||||
e.send_keys("23.95")
|
||||
e.send_keys(Keys.ENTER) # enter submit
|
||||
|
||||
# Attempt to save
|
||||
save.click()
|
||||
|
||||
newEvent = models.Event.objects.latest('pk')
|
||||
|
||||
self.assertEqual(newEvent.auth_request_to, None)
|
||||
self.assertEqual(newEvent.auth_request_by, None)
|
||||
self.assertEqual(newEvent.auth_request_at, None)
|
||||
|
||||
self.assertFalse(hasattr(newEvent, 'authorised'))
|
||||
|
||||
self.assertNotIn("N%05d" % testEvent.pk, self.browser.find_element_by_xpath('//h1').text)
|
||||
self.assertNotIn("Event data duplicated but not yet saved",
|
||||
self.browser.find_element_by_id('content').text) # Check info message not visible
|
||||
|
||||
# Check the new items are visible
|
||||
table = self.browser.find_element_by_id('item-table') # ID number is known, see above
|
||||
self.assertIn("Test Item 1", table.text)
|
||||
self.assertIn("Test Item 2", table.text)
|
||||
self.assertIn("Test Item 3", table.text)
|
||||
|
||||
infoPanel = self.browser.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
|
||||
self.assertIn("N0000%d" % testEvent.pk,
|
||||
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
||||
# Check the PO hasn't carried through
|
||||
self.assertNotIn("TESTPO", infoPanel.find_element_by_xpath('//dt[text()="PO"]/following-sibling::dd[1]').text)
|
||||
|
||||
self.assertIn("N%05d" % testEvent.pk,
|
||||
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
||||
|
||||
self.browser.get(self.live_server_url + '/event/' + str(testEvent.pk)) # Go back to the old event
|
||||
|
||||
# Check that based-on hasn't crept into the old event
|
||||
infoPanel = self.browser.find_element_by_xpath('//div[contains(text(), "Event Info")]/..')
|
||||
self.assertNotIn("N0000%d" % testEvent.pk,
|
||||
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
||||
# 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.assertNotIn("N%05d" % testEvent.pk,
|
||||
infoPanel.find_element_by_xpath('//dt[text()="Based On"]/following-sibling::dd[1]').text)
|
||||
|
||||
# Check the items are as they were
|
||||
table = self.browser.find_element_by_id('item-table') # ID number is known, see above
|
||||
self.assertIn("Test Item 1", table.text)
|
||||
self.assertIn("Test Item 2", table.text)
|
||||
self.assertNotIn("Test Item 3", table.text)
|
||||
|
||||
def testDateValidation(self):
|
||||
self.browser.get(self.live_server_url + '/event/create/')
|
||||
# Gets redirected to login and back
|
||||
|
||||
Reference in New Issue
Block a user