Skip to content

Commit e081a41

Browse files
authored
Improve unit tests (#14)
* refactor unit tests
1 parent a9e5c2e commit e081a41

File tree

111 files changed

+433
-8873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+433
-8873
lines changed

.github/workflows/CI.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency:
1212
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1313
jobs:
1414
test:
15-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
15+
name: Julia ${{ matrix.version }} - LimeSurvey ${{ matrix.lsversion }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
@@ -24,9 +24,11 @@ jobs:
2424
- ubuntu-latest
2525
arch:
2626
- x64
27+
lsversion:
28+
- 'latest'
2729
steps:
2830
- uses: actions/checkout@v2
29-
- run: docker-compose -f test/docker-compose.yml up -d --build
31+
- run: docker compose -f test/docker-compose.yml -f test/docker-compose.${{ matrix.lsversion }}.yml up -d --build
3032
- uses: julia-actions/setup-julia@v1
3133
with:
3234
version: ${{ matrix.version }}

src/CitrusAPI.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function connect!(client::CitrusClient, username::String, password::String; plug
2828
response = get_session_key(client, username, password, plugin=plugin)
2929
client.session_key = response
3030
@info "Connected to server '$(client.url)'\n\tSession key: $(client.session_key)"
31-
return nothing
31+
return response
3232
end
3333

3434
"""
@@ -39,10 +39,10 @@ Disconnect `client` from a LimeSurvey server by releasing the session key.
3939
See also: [`release_session_key`](@ref)
4040
"""
4141
function disconnect!(client::CitrusClient)
42-
release_session_key(client)
42+
response = release_session_key(client)
4343
client.session_key = nothing
4444
@info "Disconnected from server '$(client.url)'"
45-
return nothing
45+
return response
4646
end
4747

4848
# helpers

src/methods/activate_tokens.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Initialise the participants table for remote survey with `survey_id`.
77
88
See also: <https://api.limesurvey.org/classes/remotecontrol_handle.html#method_activate_tokens>
99
"""
10-
function activate_tokens!(client::CitrusClient, survey_id::Int, attribute_fields::Vector{Int}=[])
10+
function activate_tokens!(client::CitrusClient, survey_id::Int, attribute_fields=Dict())
1111
payload = construct_payload("activate_tokens", [client.session_key, survey_id, attribute_fields])
1212
response = call_limesurvey_api(client, payload)
1313
return response

src/methods/export_responses_by_token.jl

+12
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@ function export_responses_by_token(client::CitrusClient, survey_id::Int, documen
1212
response = call_limesurvey_api(client, payload)
1313
return response
1414
end
15+
16+
"""
17+
export_responses_by_token(client, survey_id, token, sink; kwargs...)
18+
19+
Export responses from remote survey with `survey_id` as a Tables.jl compatible `sink`, e.g. `DataFrame`.
20+
"""
21+
function export_responses_by_token(client::CitrusClient, survey_id::Int, token::AbstractString, sink=nothing; kwargs...)
22+
isnothing(sink) && throw(ArgumentError("Provide a valid sink argument"))
23+
response = export_responses_by_token(client, survey_id, "csv", token; kwargs...)
24+
df = base64csv_to_sink(response, sink)
25+
return df
26+
end

src/methods/list_participants.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
export list_participants
22

33
"""
4-
list_participants(client, survey_id, start; kwargs...)
4+
list_participants(client, survey_id, start=0; kwargs...)
55
66
Return a list of participants for the remote survey with `survey_id`.
7-
A start ID (`start`) must be specified.
87
98
## Keyword arguments
109
- `limit`: Number of participants to return (default: `10`)
@@ -14,7 +13,7 @@ A start ID (`start`) must be specified.
1413
1514
See also: <https://api.limesurvey.org/classes/remotecontrol_handle.html#method_list_participants>
1615
"""
17-
function list_participants(client::CitrusClient, survey_id::Int, start::Int; limit::Int=10, unused::Bool=false, attributes=false, conditions=[])
16+
function list_participants(client::CitrusClient, survey_id::Int, start::Int=0; limit::Int=10, unused::Bool=false, attributes=false, conditions=[])
1817
payload = construct_payload("list_participants", [client.session_key, survey_id, start, limit, unused, attributes, conditions])
1918
response = call_limesurvey_api(client, payload)
2019
return response

src/methods/release_session_key.jl

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export release_session_key
2-
export disconnect!
32

43
"""
54
release_session_key(client)

test/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG LS_VERSION
2+
FROM acspri/limesurvey:${LS_VERSION}
3+
COPY limesurvey/config.php /var/www/html/application/config/config.php

test/docker-compose.latest.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
limesurvey:
3+
build:
4+
args:
5+
LS_VERSION: latest

test/docker-compose.lts.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
limesurvey:
3+
build:
4+
args:
5+
LS_VERSION: lts

test/docker-compose.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
services:
22
limesurvey:
3-
image: acspri/limesurvey
3+
build:
4+
dockerfile: Dockerfile
45
ports:
56
- 8082:80
6-
volumes:
7-
- ./limesurvey/plugins:/var/www/html/plugins
8-
- ./limesurvey/upload:/var/www/html/upload
9-
- ./limesurvey/config:/var/www/html/application/config
107
environment:
118
LIMESURVEY_DB_PASSWORD: somepassword
129
LIMESURVEY_ADMIN_USER: admin

0 commit comments

Comments
 (0)