Skip to content

Commit

Permalink
test(rest): Update expected response for survey detail PATCH operation (
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Dec 8, 2023
1 parent 3ee8907 commit d6ba3e9
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 33 deletions.
4 changes: 4 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
enabled: true
titleOnly: true

scopes:
- rest
- rpc
4 changes: 2 additions & 2 deletions .github/workflows/api-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
NOXSESSION: api
steps:
- name: Check out the repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5
with:
python-version: 3.12

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
name: Build wheel and sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag || github.ref }}
- uses: actions/setup-python@v4.7.1
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: hynek/build-and-inspect-python-package@v1
Expand All @@ -39,7 +39,7 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/download-artifact@v3.0.2
- uses: actions/download-artifact@v3
with:
name: Packages
path: dist
Expand All @@ -56,7 +56,7 @@ jobs:
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- uses: actions/download-artifact@v3.0.2
- uses: actions/download-artifact@v3
with:
name: Packages
path: dist
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/gen-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

- name: Batch changes
uses: miniscruff/changie-action@v2.0.0
uses: miniscruff/changie-action@v2
with:
version: ${{ github.event.inputs.changie-version }}
args: "\
Expand All @@ -38,7 +38,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Merge changes
uses: miniscruff/changie-action@v2.0.0
uses: miniscruff/changie-action@v2
with:
version: ${{ github.event.inputs.changie-version }}
args: merge
Expand All @@ -47,7 +47,7 @@ jobs:

- name: Get the latest version
id: latest
uses: miniscruff/changie-action@v2.0.0
uses: miniscruff/changie-action@v2
with:
version: ${{ github.event.inputs.changie-version }}
args: latest
Expand All @@ -72,7 +72,7 @@ jobs:
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5.0.2
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.generate-token.outputs.token }}
title: "chore: Release ${{ steps.latest.outputs.output }}"
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Setup Python ${{ matrix.python-version }}
if: "${{ !matrix.nightly }}"
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand All @@ -131,7 +131,7 @@ jobs:
nox -s tests
- name: Upload coverage data
uses: actions/upload-artifact@v3.1.3
uses: actions/upload-artifact@v3
with:
name: coverage-unit
path: ".coverage.*"
Expand All @@ -155,10 +155,10 @@ jobs:
tags: ${{ steps.tags.outputs.tags }}
steps:
- name: Check out the repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: x64
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
engines: ${{ steps.engines.outputs.engines }}
steps:
- name: Check out the repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

- name: Test against all engines
if: ${{ contains(github.event.pull_request.labels.*.name, 'Release') || inputs.update_coverage }}
Expand Down Expand Up @@ -274,12 +274,12 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand All @@ -299,7 +299,7 @@ jobs:
echo "LS_CHECKSUM=$(shasum -a 256 ls.tar.gz | cut -d' ' -f1)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
uses: docker/setup-buildx-action@v3

- name: Get Docker
uses: actions-hub/docker/[email protected]
Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
- name: Upload coverage data
if: always()
uses: actions/upload-artifact@v3.1.3
uses: actions/upload-artifact@v3
with:
name: coverage-integration
path: ".coverage.*"
Expand All @@ -348,18 +348,18 @@ jobs:
fail-fast: false
steps:
- name: Check out the repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tools
uses: ./.github/actions/install-tools

- name: Download coverage data
uses: actions/download-artifact@v3.0.2
uses: actions/download-artifact@v3
with:
name: coverage-${{ matrix.flag }}

Expand All @@ -373,7 +373,7 @@ jobs:
nox -- xml
- name: Upload coverage report
uses: codecov/codecov-action@v3.1.4
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.2
rev: 0.27.3
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.1.7
hooks:
- id: ruff
name: Ruff lint
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,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.3.7](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.3.7%2B231127)
- [6.3.6](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.3.6%2B231120)
- [6.3.5](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.3.5%2B231113)
- [6.3.4](https://github.com/LimeSurvey/LimeSurvey/releases/tag/6.3.4%2B231108)
- [5.6.47](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.47%2B231128)
- [5.6.46](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.46%2B231121)
- [5.6.45](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.45%2B231114)
- [5.6.44](https://github.com/LimeSurvey/LimeSurvey/releases/tag/5.6.44%2B231107)

## Installation

Expand Down
2 changes: 1 addition & 1 deletion src/citric/_rest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def update_survey_details(
self,
survey_id: int,
**data: t.Any,
) -> bool:
) -> dict[str, t.Any] | bool:
"""Update survey details.
Args:
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/test_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ def test_patch_survey_details(
anonymized=not anonymized,
tokenLength=token_length + 10,
)
expected = {"operationsApplied": 1} if server_version.prerelease else True
expected = (
{
"operationsApplied": 1,
"erronousOperations": [],
}
if server_version.prerelease
else True
)
assert result == expected

updated = rest_client.get_survey_details(survey_id=survey_id)
Expand Down
11 changes: 9 additions & 2 deletions tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ def handler(request: Request) -> Response:
],
)
return Response(
json.dumps(True), # noqa: FBT003
json.dumps(
{
"operationsApplied": len(request.json["patch"]), # type: ignore[index]
"erronousOperations": [],
},
),
content_type=content_type,
)

Expand Down Expand Up @@ -177,7 +182,9 @@ def test_update_survey_details(
anonymized=True,
tokenLength=10,
)
assert result is True
assert isinstance(result, dict)
assert result["operationsApplied"] == 1
assert result["erronousOperations"] == []

surveys = backend.table("surveys")
survey = surveys.get(doc_id=12345)
Expand Down

0 comments on commit d6ba3e9

Please sign in to comment.