From 6f61afa52a1dddd560b4ade8d354769ad511cfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Rami=CC=81rez=20Mondrago=CC=81n?= Date: Tue, 4 Apr 2023 17:35:27 -0600 Subject: [PATCH] feat: Remove warnings for LimeSurvey 6.0 features --- docker-compose.ref.yml | 2 +- docker-compose.yml | 2 +- docs/_ext/limesurvey_future.py | 30 ++++++++++++++++++++---------- src/citric/client.py | 17 ++++++----------- tests/test_integration.py | 2 -- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/docker-compose.ref.yml b/docker-compose.ref.yml index 2ad8e15c..82fb8c06 100644 --- a/docker-compose.ref.yml +++ b/docker-compose.ref.yml @@ -2,7 +2,7 @@ services: limesurvey: image: edgarrmondragon/limesurvey build: - context: ${LS_DOCKERFILE_CONTEXT:-https://github.com/martialblog/docker-limesurvey.git#master:5.0/apache} + context: ${LS_DOCKERFILE_CONTEXT:-https://github.com/martialblog/docker-limesurvey.git#master:6.0/apache} dockerfile: ${LS_DOCKERFILE:-Dockerfile} args: version: ${LS_VERSION} diff --git a/docker-compose.yml b/docker-compose.yml index 77147ca9..c4697656 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: limesurvey: - image: martialblog/limesurvey:${LS_IMAGE_TAG:-5-apache} + image: martialblog/limesurvey:${LS_IMAGE_TAG:-6-apache} volumes: - "surveys:/var/www/html/upload/surveys" - "apache:/var/log/apache2" diff --git a/docs/_ext/limesurvey_future.py b/docs/_ext/limesurvey_future.py index 12381fd7..6c087d74 100644 --- a/docs/_ext/limesurvey_future.py +++ b/docs/_ext/limesurvey_future.py @@ -10,6 +10,8 @@ if TYPE_CHECKING: from sphinx.application import Sphinx +__all__ = ["ReleasedFeature", "UnreleasedFeature", "setup"] + class UnreleasedFeature(Directive): """A directive for development-only features. @@ -19,23 +21,31 @@ class UnreleasedFeature(Directive): """ required_arguments = 1 + message = ( + "This method is only supported in LimeSurvey >= {next_version} " + "(currently in development)." + ) + admonition_type = nodes.warning def run(self) -> list[nodes.Node]: next_version = self.arguments[0] - admonition_node = nodes.warning( - "", - nodes.paragraph( - text=( - f"This method is only available in LimeSurvey >= {next_version} " - "(currently in development)." - ), - ), - ) - return [admonition_node] + text = self.message.format(next_version=next_version) + return [self.admonition_type("", nodes.paragraph(text=text))] + + +class ReleasedFeature(UnreleasedFeature): + """A directive for released features. + + Adds a note to features only available after some release of LimeSurvey. + """ + + message = "This method is only supported in LimeSurvey >= {next_version}." + admonition_type = nodes.note def setup(app: Sphinx) -> dict[str, Any]: app.add_directive("future", UnreleasedFeature) + app.add_directive("minlimesurvey", ReleasedFeature) return { "version": "0.1", diff --git a/src/citric/client.py b/src/citric/client.py index 3329f4ad..edb092a4 100644 --- a/src/citric/client.py +++ b/src/citric/client.py @@ -12,7 +12,6 @@ import requests from citric import enums -from citric._compat import future from citric.session import Session if TYPE_CHECKING: @@ -228,7 +227,6 @@ def add_participants( create_tokens, ) - @future("6.0") def add_quota( self, survey_id: int, @@ -259,7 +257,7 @@ def add_quota( ID of the newly created quota. .. versionadded:: 0.6.0 - .. future:: 6.0 + .. minlimesurvey:: 6.0.0 """ return self.session.add_quota( survey_id, @@ -512,7 +510,6 @@ def delete_language(self, survey_id: int, language: str) -> types.OperationStatu """ return self.__session.delete_language(survey_id, language) - @future("6.0") def delete_quota(self, quota_id: int) -> types.OperationStatus: """Delete a LimeSurvey quota. @@ -523,7 +520,7 @@ def delete_quota(self, quota_id: int) -> types.OperationStatus: True if the quota was deleted. .. versionadded:: 0.6.0 - .. future:: 6.0 + .. minlimesurvey:: 6.0.0 """ return self.session.delete_quota(quota_id) @@ -851,7 +848,6 @@ def get_question_properties( """ return self.__session.get_question_properties(question_id, settings, language) - @future("6.0") def get_quota_properties( self, quota_id: int, @@ -869,7 +865,7 @@ def get_quota_properties( Quota properties. .. versionadded:: 0.6.0 - .. future:: 6.0 + .. minlimesurvey:: 6.0.0 """ return self.session.get_quota_properties(quota_id, settings, language) @@ -889,7 +885,6 @@ def get_response_ids( """ return self.__session.get_response_ids(survey_id, token) - @future("6.0") def get_available_site_settings(self) -> list[str]: """Get all available site settings. @@ -897,7 +892,8 @@ def get_available_site_settings(self) -> list[str]: A list of all the available site settings. .. versionadded:: 0.6.0 - .. future:: 6.0 + .. future: 6.0.0 + .. minlimesurvey:: 6.0.0 """ return self.session.get_available_site_settings() @@ -1216,7 +1212,6 @@ def list_questions( """ return self.__session.list_questions(survey_id, group_id, language) - @future("6.0") def list_quotas(self, survey_id: int) -> list[types.QuotaListElement]: """Get all quotas for a LimeSurvey survey. @@ -1227,7 +1222,7 @@ def list_quotas(self, survey_id: int) -> list[types.QuotaListElement]: List of quotas. .. versionadded:: 0.6.0 - .. future:: 6.0 + .. minlimesurvey:: 6.0.0 """ return self.session.list_quotas(survey_id) diff --git a/tests/test_integration.py b/tests/test_integration.py index 04e6883a..1d9456f6 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -202,7 +202,6 @@ def test_question(client: citric.Client, survey_id: int): @pytest.mark.integration_test -@pytest.mark.version("develop") def test_quota(client: citric.Client, survey_id: int): """Test quota methods.""" with pytest.raises(LimeSurveyStatusError, match="No quotas found"): @@ -488,7 +487,6 @@ def test_file_upload_invalid_extension( @pytest.mark.integration_test -@pytest.mark.version("develop") def test_get_available_site_settings(client: citric.Client): """Test getting available site settings.""" assert client.get_available_site_settings()