Change to pytest-style assertions

This commit is contained in:
Anna Sidwell 2019-08-20 00:40:23 +02:00
parent 03a72e5480
commit 03eecf6461

View File

@ -111,7 +111,7 @@ class MapTest(SeleniumTest):
# click submit without filling in any fields
self.sl.find_element_by_id("submit-id-submit").click()
error_message = self.sl.find_element_by_class_name("has-error")
self.assertTrue(error_message.is_displayed())
assert error_message.is_displayed() is True
def test_short_form_will_submit(self):
self._open("/en-gb/case-study/create/short")
@ -144,9 +144,9 @@ class MapTest(SeleniumTest):
)
# you can submit the form on any field. Using this one because the submit button sometimes isn't visible
self.sl.find_element_by_id("id_area_of_land").submit()
self.assertTrue("Thanks!" in self.sl.page_source, "Success message not shown")
assert "Thanks!" in self.sl.page_source, "Success message not shown"
self._open("/admin/map/casestudy/")
self.assertTrue("Short Entry" in self.sl.page_source, "Case study not saved")
assert "Short Entry" in self.sl.page_source, "Case study not saved"
def test_long_form_will_submit(self):
self._open("/en-gb/case-study/create/long")
@ -188,9 +188,9 @@ class MapTest(SeleniumTest):
self.sl.find_element_by_css_selector('a[href="#uploads"]').click()
# you can submit the form on any field. Using this one because the submit button sometimes isn't visible
self.sl.find_element_by_id("id_name_of_territory_or_area").submit()
self.assertTrue("Thanks!" in self.sl.page_source, "Success message not shown")
assert "Thanks!" in self.sl.page_source, "Success message not shown"
self._open("/admin/map/casestudy/")
self.assertTrue("Long Entry" in self.sl.page_source, "Case study not saved")
assert "Long Entry" in self.sl.page_source, "Case study not saved"
def test_map(self):
self._open("/")
@ -212,8 +212,8 @@ class MapTest(SeleniumTest):
details_link = self.sl.find_element_by_css_selector(
".leaflet-popup-content a.btn"
)
self.assertTrue(details_link.is_displayed())
assert details_link.is_displayed() is True
details_link.click()
self.assertTrue(self.sl.current_url.endswith("case-study/test"))
assert self.sl.current_url.endswith("case-study/test") is True