def test_get_dataset_activity(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_activity = [{
                    "download_history": [],
                    "id":
                    356,
                    "licence_agreed":
                    False,
                    "name":
                    "ccod",
                    "private":
                    False,
                    "title":
                    "UK companies that own property in England and Wales"
                }]

                mock_get.return_value.json.return_value = dataset_activity
                mock_get.return_value.status_code = 200

                response = UlapdAPI.get_dataset_activity(self, 1)

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

                self.assertEqual(response, dataset_activity)
    def test_get_dataset_activity_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_dataset_activity(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)