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

Routes & tests #45

Merged
merged 45 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
20d0b66
remove deprecated test
jmargutt Oct 18, 2024
ba6573f
remove imports of unused modules
jmargutt Oct 18, 2024
1ffe3a8
bug fixed espo routes
jmargutt Oct 18, 2024
5bd800f
bug fix dockerfile
jmargutt Oct 18, 2024
1771993
add link related entity based on field
jmargutt Oct 19, 2024
7e5f728
add explanation related field
jmargutt Oct 19, 2024
afcb0c6
bug fix related entity
jmargutt Oct 19, 2024
5d4cf7d
bug fix related entity
jmargutt Oct 19, 2024
0c12b4f
test health and kobo-to-121
tijsziere Oct 22, 2024
a280916
remove print
tijsziere Oct 22, 2024
748410f
add skipconnect test 121
tijsziere Oct 22, 2024
6857ee2
fix bug
tijsziere Oct 22, 2024
84ae087
update test
tijsziere Oct 22, 2024
d71ccd1
Merge pull request #46 from rodekruis/feat.tests
tijsziere Oct 22, 2024
a91869a
remove deprecated test
jmargutt Oct 18, 2024
381d451
remove imports of unused modules
jmargutt Oct 18, 2024
fe2e911
bug fixed espo routes
jmargutt Oct 18, 2024
f07bd55
bug fix dockerfile
jmargutt Oct 18, 2024
15241b4
add link related entity based on field
jmargutt Oct 19, 2024
cbd1f82
add explanation related field
jmargutt Oct 19, 2024
b90faa6
bug fix related entity
jmargutt Oct 19, 2024
9002a4f
bug fix related entity
jmargutt Oct 19, 2024
656fafd
fix bug
tijsziere Oct 22, 2024
b102084
test health and kobo-to-121
tijsziere Oct 22, 2024
b78bdf4
remove print
tijsziere Oct 22, 2024
053cdf3
add skipconnect test 121
tijsziere Oct 22, 2024
9570c14
update test
tijsziere Oct 22, 2024
7407812
reinclude reverted files
tijsziere Oct 22, 2024
44a465f
Merge pull request #49 from rodekruis/dev-final
tijsziere Oct 22, 2024
ae050ed
change workflow
tijsziere Oct 22, 2024
ab942b6
fix main
tijsziere Oct 22, 2024
1ff83ae
add requirements.txt
tijsziere Oct 24, 2024
b91f93d
update requirements.txt
tijsziere Oct 24, 2024
a5c6a35
update workflow
tijsziere Oct 24, 2024
2b2c424
use pyproject.toml
tijsziere Oct 24, 2024
d3bb427
Merge branch 'main' into dev
tijsziere Oct 24, 2024
487b111
update requirements
tijsziere Oct 24, 2024
2dfe927
update poetry.lock
tijsziere Oct 24, 2024
a7d55f3
update test workflow
tijsziere Oct 24, 2024
3b6ffe8
update test workflow
tijsziere Oct 24, 2024
c3e0fae
incl secrets
tijsziere Oct 24, 2024
e45d6f5
add tests (+ small fixes)
tijsziere Oct 24, 2024
f43a516
update example.env
tijsziere Oct 24, 2024
e0ed23e
add github secrets
tijsziere Oct 24, 2024
34669bb
add tests and fix format
jmargutt Oct 31, 2024
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
11 changes: 9 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
name: Run automated Tests

on:
push:
workflow_dispatch:
pull_request:

Expand All @@ -26,7 +25,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then pip install .; fi
- name: Set up environment variables
run: |
echo "APPLICATIONINSIGHTS_CONNECTION_STRING=${{ secrets.APPLICATIONINSIGHTS_CONNECTION_STRING }}" >> $GITHUB_ENV
echo "COSMOS_URL=${{ secrets.COSMOS_URL }}" >> $GITHUB_ENV
echo "COSMOS_KEY=${{ secrets.COSMOS_KEY }}" >> $GITHUB_ENV
echo "PORT=${{ secrets.PORT }}" >> $GITHUB_ENV
echo "TEST_KOBO_ASSETID=${{ secrets.TEST_KOBO_ASSETID }}" >> $GITHUB_ENV
echo "TEST_KOBO_TOKEN=${{ secrets.TEST_KOBO_TOKEN }}" >> $GITHUB_ENV
- name: Test with pytest
run: |
pytest
29 changes: 0 additions & 29 deletions .github/workflows/test-submission.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ FROM python:3.11-slim
# copy files to the /app folder in the container
ADD clients /app/clients
ADD mappings /app/mappings
ADD routes /app/routes
ADD utils /app/utils
ADD tests /app/tests
COPY ./main.py /app/main.py
COPY ./pyproject.toml /app/pyproject.toml
COPY ./poetry.lock /app/poetry.lock
Expand Down
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Using the [`kobo-to-espocrm`](https://kobo-connect.azurewebsites.net/docs#/defau
```
https://kobo-connect.azurewebsites.net/kobo-to-espocrm
```
6. In Kobo REST Services, add under `Custom HTTP Headers`:
- In `Name` add `targeturl` with in the `Value` the EspoCRM URL (for example, https://espocrminstancex.com).
- In `Name` add `targetkey` with in the `Value` the (newly) created API Key (from EspoCRM API User).
9. For each question, add a `Custom HTTP Header` that specifies which Kobo questions responds to which entity and field EspoCRM:
- The header `Name` (left) must correspond to the Kobo question **name**. (You can check the Kobo question name by going into edit mode of the form, open 'Settings' of the specific question and inspect the `Data Column Name`. Also, the Kobo question names can be found in the 'Data' table with previous submissions. This Kobo question name is different from the [Kobo question label](https://support.kobotoolbox.org/getting_started_xlsform.html#adding-questions) and can not contain spaces or symbols (except the underscore).).
6. In Kobo REST Services, add a header under `Custom HTTP Headers`:
- Under `Name` insert `targeturl` and under `Value` the EspoCRM URL (for example, https://espocrminstancex.com).
- Under `Name` insert `targetkey` and under `Value` the (newly) created API Key (from EspoCRM API User).
9. For each question, add a header that specifies which Kobo questions corresponds to which entity and field EspoCRM:
- The header name (left) must correspond to the Kobo question **name**. (You can check the Kobo question name by going into edit mode of the form, open 'Settings' of the specific question and inspect the `Data Column Name`. Also, the Kobo question names can be found in the 'Data' table with previous submissions. This Kobo question name is different from the [Kobo question label](https://support.kobotoolbox.org/getting_started_xlsform.html#adding-questions) and can not contain spaces or symbols (except the underscore).).
- The header value (right) must correspond to the EspoCRM entity **name**, followed by a dot (`.`), followed by the specific field **name**. Example: `Contact.name`. (EspoCRM name is different from the EspoCRM label, similar to the difference between Kobo question name and Kobo question label).

> [!IMPORTANT]
Expand All @@ -40,23 +40,30 @@ https://kobo-connect.azurewebsites.net/kobo-to-espocrm
- If you have a question of type `Select Many` (`select_multiple`) in Kobo and you want to save it in a field of type `Multi-Enum` in EspoCRM, add `multi.` before the Kobo question name in the header name.
- Example header: `multi.multiquestion1`: `Entity.field1`
- If you have a **repeating group** of questions in Kobo:
- you will need to save each repeated question in a different field in EspoCRM;
- in the header name:
- add `repeat.`, followed by the repeating group name, followed by a dot (`.`);
- then add a number to specify the number of the repeated question (starting from 0), followed by a dot (`.`);
- then add the name of the repeated question after the number;
- in the header value:
- as before, use the entity name, followed by a dot (`.`), followed by the field name in EspoCRM.
- you will need to save each repeated question in a different field in EspoCRM, as specified by a different header;
- under each header name:
- insert `repeat.`, followed by the repeating group name, followed by a dot (`.`);
- then insert a number to specify the number of the repeated question (starting from 0), followed by a dot (`.`);
- then insert the name of the repeated question after the number;
- under each header value:
- as before, insert the entity name, followed by a dot (`.`), followed by the field name in EspoCRM.
- Example headers:
- `repeat.repeatedgroup.0.repeatedquestion`: `Entity.field1`
- `repeat.repeatedgroup.1.repeatedquestion`: `Entity.field2`
- Not all repeated questions need to be filled in nor saved to EspoCRM.
- If you need to **update** a pre-existing record:
- add a question of type `calculate` called `updaterecordby` in the Kobo form, which will contain the value of the field which you will use to identify the record;
- add a `Custom HTTP Header` called `updaterecordby` with the name of the field that you will use to identify the record.
- add a header with name `updaterecordby` and as value the name of the field that you will use to identify the record.
- If you need to **avoid sending specific submissions** to EspoCRM:
- add a question called `skipconnect` in the Kobo form;
- whenever its value is `1` (based on some condition), the submission will not be sent to EspoCRM.
- If you need to **link the new record with another pre-existing record in** EspoCRM:
- ensure that the API user has read-access to the related entity;
- under the header name insert the name of the Kobo question, as usual;
- under the header value insert the entity name, followed by a dot (`.`), followed by the field name of type `Link` (the one containing the related entity record), followed by a dot (`.`), followed by the field name of the related entity used to relate the two.
- Example headers:
- `pcode`: `Entity.AdminLevel1.pcode`
- `programCode`: `Entity.program.code`

## 121

Expand Down
Empty file added __init__.py
Empty file.
5 changes: 5 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
PORT=8000
COSMOS_URL =
COSMOS_KEY =
APPLICATIONINSIGHTS_CONNECTION_STRING =
TEST_KOBO_TOKEN =
TEST_KOBO_ASSETID =
Loading
Loading