Skip to content

Commit

Permalink
feat: implement delete_language in client (#208)
Browse files Browse the repository at this point in the history
* feat: implement delete_language in client

* Update test_language

* fix: should call get_survey_properties again
  • Loading branch information
edgarrmondragon committed Mar 24, 2022
1 parent 146231a commit 69dc62c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/api_coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
| `copy_survey` | Yes | Copy survey (RPC function) |
| `cpd_importParticipants` | No | Import a participant into the LimeSurvey CPDB |
| `delete_group` | Yes | Delete a group from a chosen survey (RPC function) |
| `delete_language` | No | Delete a language from a survey (RPC function) |
| `delete_language` | Yes | Delete a language from a survey (RPC function) |
| `delete_participants` | Yes | Delete multiple participants from the survey participants table (RPC function) |
| `delete_question` | No | Delete question from a survey (RPC function) |
| `delete_response` | Yes | Delete a response in a given survey using its Id |
Expand Down
14 changes: 14 additions & 0 deletions src/citric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ def delete_group(self, survey_id: int, group_id: int) -> int:
"""
return self.__session.delete_group(survey_id, group_id)

def delete_language(self, survey_id: int, language: str) -> dict[str, str]:
"""Delete a language from a survey.
Requires at LimeSurvey >= 5.3.4.
Args:
survey_id: ID of the Survey for which a language will be deleted from.
language: Language to delete.
Returns:
Status message.
"""
return self.__session.delete_language(survey_id, language)

def delete_response(self, survey_id: int, response_id: int) -> dict[str, str]:
"""Delete a response in a survey.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ def test_delete_group(client: MockClient):
assert_client_session_call(client, "delete_group", 1, 10)


def test_delete_language(client: MockClient):
"""Test delete_language client method."""
assert_client_session_call(client, "delete_language", 1, "ru")


def test_delete_response(client: MockClient):
"""Test delete_response client method."""
assert_client_session_call(client, "delete_response", 1, 1)
Expand Down
7 changes: 7 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ def test_language(client: citric.Client, survey_id: int):
)
assert new_props["surveyls_email_confirm"] == new_confirmation

# Delete language
response = client.delete_language(survey_id, "ru")
assert response["status"] == "OK"

props_after_delete_language = client.get_survey_properties(survey_id)
assert props_after_delete_language["additional_languages"] == "es"


@pytest.mark.integration_test
def test_survey(client: citric.Client):
Expand Down

0 comments on commit 69dc62c

Please sign in to comment.