Skip to content

Commit

Permalink
feat(rpc): Add get_db_version method to RPC client
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 18, 2024
1 parent 875a638 commit 65348d9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@

Integration tests are run against a LimeSurvey instance, and both PostgreSQL and MySQL backends, using Docker Compose. The following versions of LimeSurvey were tested for this release:

- [6.4.1](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.4.1+240108)
- [6.4.0](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.4.0+231218)
- [6.3.9](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.3.9+231211)
- [6.3.8](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.3.8+231204)
- [5.6.50](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.50+240109)
- [5.6.49](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.49+231212)
- [5.6.48](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.48+231205)
- [5.6.47](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.47+231128)

## Installation

Expand Down
12 changes: 12 additions & 0 deletions src/citric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,18 @@ def get_server_version(self) -> str:
"""
return self._get_site_setting("versionnumber")

def get_db_version(self) -> int:
"""Get the LimeSurvey database version.
Calls :rpc_method:`get_site_settings("dbversionnumber") <get_site_settings>`.
Returns:
The LimeSurvey database version.
.. versionadded:: NEXT_VERSION
"""
return self._get_site_setting("dbversionnumber")

def get_summary(self, survey_id: int) -> dict[str, int]:
"""Get survey summary.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ def server_version(client: citric.Client) -> semver.Version:
@pytest.fixture(scope="session")
def database_version(client: citric.Client) -> int:
"""Get the LimeSurvey database schema version."""
return client._get_site_setting("dbversionnumber")
return client.get_db_version()
12 changes: 12 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class MockSession(Session):
"sitename": "mock-site",
"defaultlang": "mock-lang",
"restrictToLanguages": "en fr es",
"versionnumber": "6.0.0",
"dbversionnumber": 321,
}

def rpc(self, method: str, *params: t.Any) -> dict[str, t.Any]:
Expand Down Expand Up @@ -427,6 +429,16 @@ def test_get_available_languages(client: MockClient):
assert client.get_available_languages() == ["en", "fr", "es"]


def test_get_server_version(client: MockClient):
"""Test get server version."""
assert client.get_server_version() == "6.0.0"


def test_get_database_version(client: MockClient):
"""Test get database version."""
assert client.get_db_version() == 321


def test_import_group(client: MockClient, tmp_path: Path):
"""Test import_group client method."""
random_bytes = randbytes(100)
Expand Down

0 comments on commit 65348d9

Please sign in to comment.