def test_get_user_dataset_access(self, mock_get):
        with app.app_context() as ac:
            ac.g.trace_id = None
            ac.g.requests = requests.Session()
            with app.test_request_context():
                dataset_access = [{
                    'name': 'res_cov',
                    'title': 'Restrictive Covenants',
                    'licences': {
                        'res_cov_direct': {
                            'title': 'Direct Use',
                            'agreed': True
                        }
                    }
                }]

                mock_get.return_value.json.return_value = dataset_access
                mock_get.return_value.status_code = 200

                response = UlapdAPI.get_user_dataset_access(self, 1)

                mock_get.assert_called_once()
                mock_get.assert_called_with(
                    '{0}/users/dataset-access/{1}'.format(self.url, 1),
                    headers=self.headers,
                    timeout=self.timeout)

                self.assertEqual(response, dataset_access)
    def test_get_user_dataset_access_connection_error(self, mock_get):
        with app.app_context() as ac:
            ac.g.trace_id = None
            ac.g.requests = requests.Session()
            with app.test_request_context():
                mock_get.side_effect = ConnectionError(self.error_msg)

                with self.assertRaises(ApplicationError) as context:
                    UlapdAPI.get_user_dataset_access(self, 1)

                expected_err = ('verification_api', 'ULAPD_API_CONN_ERROR')
                expected_err_message = errors.get_message(
                    *expected_err, filler=self.error_msg)
                expected_err_code = errors.get_code(*expected_err)

                mock_get.assert_called_once()
                self.assertEqual(context.exception.message,
                                 expected_err_message)
                self.assertEqual(context.exception.code, expected_err_code)