Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve unit tests #14

Merged
merged 31 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
31481d8
refactor unit tests
p-gw Nov 28, 2022
9123c29
set client outside of testset
p-gw Nov 28, 2022
5a3de38
fix test errors
p-gw Nov 28, 2022
7fcf3d2
test against lts and latest limesurvey version
p-gw Nov 28, 2022
7917ef6
fix unit test
p-gw Nov 28, 2022
82f1fa9
add tests for question groups
p-gw Nov 29, 2022
0b7d02f
add tests for questions
p-gw Nov 29, 2022
eb51b3b
debug tests
p-gw Nov 29, 2022
13e27a8
fix tests
p-gw Nov 29, 2022
13327e7
add tests for responses
p-gw Nov 29, 2022
e4bc8a5
fix undef reference
p-gw Nov 29, 2022
c9ee39a
fix
p-gw Nov 29, 2022
4730cc6
set new default values
p-gw Nov 29, 2022
196f6d7
add tests for participants
p-gw Nov 29, 2022
958f53d
fix tests
p-gw Nov 29, 2022
3cacad4
require isequal due to missings
p-gw Nov 29, 2022
21661c8
add sink method for export_responses_by_token
p-gw Nov 29, 2022
6c26278
more tests for responses
p-gw Nov 29, 2022
45b241f
keep 1 participant
p-gw Nov 29, 2022
4fbe185
factor in additional response for token
p-gw Nov 29, 2022
684e12e
add remaining tests
p-gw Nov 29, 2022
580dc01
also run tests on LimeSurvey LTS
p-gw Nov 29, 2022
40d4e25
add new constructed survey
p-gw Nov 29, 2022
587b292
change tests for new survey
p-gw Nov 30, 2022
fc9738a
fix tests on limesurvey latest
p-gw Nov 30, 2022
def5aff
additional fixes for latest
p-gw Nov 30, 2022
c0d7bea
test with new docker config
p-gw Dec 1, 2022
4b2d95c
fix CI command
p-gw Dec 1, 2022
04fa9f0
fix broken tests
p-gw Dec 1, 2022
d305558
fix typo
p-gw Dec 1, 2022
2b85f91
omit tests for limesurvey lts
p-gw Dec 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Julia ${{ matrix.version }} - LimeSurvey ${{ matrix.lsversion }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -24,9 +24,11 @@ jobs:
- ubuntu-latest
arch:
- x64
lsversion:
- 'latest'
steps:
- uses: actions/checkout@v2
- run: docker-compose -f test/docker-compose.yml up -d --build
- run: docker compose -f test/docker-compose.yml -f test/docker-compose.${{ matrix.lsversion }}.yml up -d --build
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand Down
6 changes: 3 additions & 3 deletions src/CitrusAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function connect!(client::CitrusClient, username::String, password::String; plug
response = get_session_key(client, username, password, plugin=plugin)
client.session_key = response
@info "Connected to server '$(client.url)'\n\tSession key: $(client.session_key)"
return nothing
return response
end

"""
Expand All @@ -39,10 +39,10 @@ Disconnect `client` from a LimeSurvey server by releasing the session key.
See also: [`release_session_key`](@ref)
"""
function disconnect!(client::CitrusClient)
release_session_key(client)
response = release_session_key(client)
client.session_key = nothing
@info "Disconnected from server '$(client.url)'"
return nothing
return response
end

# helpers
Expand Down
2 changes: 1 addition & 1 deletion src/methods/activate_tokens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Initialise the participants table for remote survey with `survey_id`.

See also: <https://api.limesurvey.org/classes/remotecontrol_handle.html#method_activate_tokens>
"""
function activate_tokens!(client::CitrusClient, survey_id::Int, attribute_fields::Vector{Int}=[])
function activate_tokens!(client::CitrusClient, survey_id::Int, attribute_fields=Dict())
payload = construct_payload("activate_tokens", [client.session_key, survey_id, attribute_fields])
response = call_limesurvey_api(client, payload)
return response
Expand Down
12 changes: 12 additions & 0 deletions src/methods/export_responses_by_token.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ function export_responses_by_token(client::CitrusClient, survey_id::Int, documen
response = call_limesurvey_api(client, payload)
return response
end

"""
export_responses_by_token(client, survey_id, token, sink; kwargs...)

Export responses from remote survey with `survey_id` as a Tables.jl compatible `sink`, e.g. `DataFrame`.
"""
function export_responses_by_token(client::CitrusClient, survey_id::Int, token::AbstractString, sink=nothing; kwargs...)
isnothing(sink) && throw(ArgumentError("Provide a valid sink argument"))
response = export_responses_by_token(client, survey_id, "csv", token; kwargs...)
df = base64csv_to_sink(response, sink)
return df
end
5 changes: 2 additions & 3 deletions src/methods/list_participants.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export list_participants

"""
list_participants(client, survey_id, start; kwargs...)
list_participants(client, survey_id, start=0; kwargs...)

Return a list of participants for the remote survey with `survey_id`.
A start ID (`start`) must be specified.

## Keyword arguments
- `limit`: Number of participants to return (default: `10`)
Expand All @@ -14,7 +13,7 @@ A start ID (`start`) must be specified.

See also: <https://api.limesurvey.org/classes/remotecontrol_handle.html#method_list_participants>
"""
function list_participants(client::CitrusClient, survey_id::Int, start::Int; limit::Int=10, unused::Bool=false, attributes=false, conditions=[])
function list_participants(client::CitrusClient, survey_id::Int, start::Int=0; limit::Int=10, unused::Bool=false, attributes=false, conditions=[])
payload = construct_payload("list_participants", [client.session_key, survey_id, start, limit, unused, attributes, conditions])
response = call_limesurvey_api(client, payload)
return response
Expand Down
1 change: 0 additions & 1 deletion src/methods/release_session_key.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export release_session_key
export disconnect!

"""
release_session_key(client)
Expand Down
3 changes: 3 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARG LS_VERSION
FROM acspri/limesurvey:${LS_VERSION}
COPY limesurvey/config.php /var/www/html/application/config/config.php
5 changes: 5 additions & 0 deletions test/docker-compose.latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
limesurvey:
build:
args:
LS_VERSION: latest
5 changes: 5 additions & 0 deletions test/docker-compose.lts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
limesurvey:
build:
args:
LS_VERSION: lts
7 changes: 2 additions & 5 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
services:
limesurvey:
image: acspri/limesurvey
build:
dockerfile: Dockerfile
ports:
- 8082:80
volumes:
- ./limesurvey/plugins:/var/www/html/plugins
- ./limesurvey/upload:/var/www/html/upload
- ./limesurvey/config:/var/www/html/application/config
environment:
LIMESURVEY_DB_PASSWORD: somepassword
LIMESURVEY_ADMIN_USER: admin
Expand Down
Loading