Improve code coverage

This commit is contained in:
Álvaro Arranz 2018-07-16 09:02:47 +02:00
parent a6eb52bb9d
commit 6edcb98629
No known key found for this signature in database
GPG Key ID: A9BA9AAE8CF561AB
2 changed files with 12 additions and 3 deletions

View File

@ -83,7 +83,7 @@ class TestSelenium(unittest.TestCase):
def tearDown(self):
self.driver.get(self.base_url)
try:
try: # pragma: no cover
# Accept any "Are you sure to leave?" alert
self.driver.switch_to.alert.accept()
self.driver.switch_to.default_content()
@ -206,7 +206,7 @@ class TestSelenium(unittest.TestCase):
try:
# The link button is only clicked if it's present
driver.find_element_by_link_text('Link').click()
except Exception:
except Exception: # pragma: no cover
pass
driver.find_element_by_id('field-image-url').clear()

View File

@ -37,7 +37,7 @@ class ViewsTest(unittest.TestCase):
# Configure the mocks
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
# Call the function
@ -84,3 +84,12 @@ class ViewsTest(unittest.TestCase):
# 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()})
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())