Improve code coverage
This commit is contained in:
parent
a6eb52bb9d
commit
6edcb98629
|
@ -83,7 +83,7 @@ class TestSelenium(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.driver.get(self.base_url)
|
self.driver.get(self.base_url)
|
||||||
try:
|
try: # pragma: no cover
|
||||||
# Accept any "Are you sure to leave?" alert
|
# Accept any "Are you sure to leave?" alert
|
||||||
self.driver.switch_to.alert.accept()
|
self.driver.switch_to.alert.accept()
|
||||||
self.driver.switch_to.default_content()
|
self.driver.switch_to.default_content()
|
||||||
|
@ -206,7 +206,7 @@ class TestSelenium(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
# The link button is only clicked if it's present
|
# The link button is only clicked if it's present
|
||||||
driver.find_element_by_link_text('Link').click()
|
driver.find_element_by_link_text('Link').click()
|
||||||
except Exception:
|
except Exception: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
|
|
||||||
driver.find_element_by_id('field-image-url').clear()
|
driver.find_element_by_id('field-image-url').clear()
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ViewsTest(unittest.TestCase):
|
||||||
|
|
||||||
# Configure the mocks
|
# Configure the mocks
|
||||||
setattr(logic, exception, ValueError)
|
setattr(logic, exception, ValueError)
|
||||||
toolkit.get_action().side_effect=getattr(logic, exception)
|
toolkit.get_action().side_effect = getattr(logic, exception)
|
||||||
base.abort.side_effect = TypeError
|
base.abort.side_effect = TypeError
|
||||||
|
|
||||||
# Call the function
|
# Call the function
|
||||||
|
@ -84,3 +84,12 @@ class ViewsTest(unittest.TestCase):
|
||||||
# Check that the render method has been called
|
# Check that the render method has been called
|
||||||
base.render.assert_called_once_with('user/dashboard_acquired.html', {'user_dict': default_user, 'acquired_datasets': acquisitions_list()})
|
base.render.assert_called_once_with('user/dashboard_acquired.html', {'user_dict': default_user, 'acquired_datasets': acquisitions_list()})
|
||||||
self.assertEqual(returned, base.render())
|
self.assertEqual(returned, base.render())
|
||||||
|
|
||||||
|
@patch("ckanext.privatedatasets.views.acquired_datasets")
|
||||||
|
def test_there_is_a_controller_for_ckan_27(self, acquired_datasets):
|
||||||
|
controller = views.AcquiredDatasetsControllerUI()
|
||||||
|
|
||||||
|
response = controller.acquired_datasets()
|
||||||
|
|
||||||
|
acquired_datasets.assert_called_once_with()
|
||||||
|
self.assertEqual(response, acquired_datasets())
|
||||||
|
|
Loading…
Reference in New Issue