Skip to content

Commit cedb5fd

Browse files
authored
::white_check_mark: use code samples for integration testing (#124)
1 parent 9323ffa commit cedb5fd

20 files changed

+106
-9
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Publish Documentation to GitHub pages.
33
#
4-
name: Documentation
4+
name: Publish Documentation
55

66
on:
77
release:

.github/workflows/license.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/cache@v3
2727
with:
2828
path: ~/.cache/pip
29-
key: ${{ runner.os }}-lic-${{ hashFiles('**/setup.py') }}
29+
key: ${{ runner.os }}-lic-${{ hashFiles('**/setup.cfg') }}
3030
restore-keys: |
3131
${{ runner.os }}-lic-
3232
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test Code Samples
2+
3+
on:
4+
pull_request:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
# Allow running this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
jobs:
12+
test:
13+
name: Run Tests
14+
timeout-minutes: 30
15+
strategy:
16+
matrix:
17+
python-version:
18+
- "3.7"
19+
- "3.11"
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
with:
24+
submodules: recursive
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Cache dependencies
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/.cache/pip
35+
key: ${{ runner.os }}-samples-${{ hashFiles('**/setup.cfg') }}
36+
restore-keys: |
37+
${{ runner.os }}-samples-
38+
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install pip
42+
pip install -e .
43+
44+
- name: Tests code samples
45+
run: |
46+
./tests/test_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }} ${{ secrets.MINDEE_API_KEY_SE_TESTS }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: actions/cache@v3
3737
with:
3838
path: ~/.cache/pip
39-
key: ${{ runner.os }}-test-${{ hashFiles('**/setup.py') }}
39+
key: ${{ runner.os }}-test-${{ hashFiles('**/setup.cfg') }}
4040
restore-keys: |
4141
${{ runner.os }}-test-
4242

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,4 @@ dmypy.json
136136
# Temp files
137137
*.swp
138138
*-swp
139+
_test.py
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from mindee import Client, documents
2+
3+
# Init a new client
4+
mindee_client = Client(api_key="my-api-key")
5+
6+
# Load a file from disk
7+
input_doc = mindee_client.doc_from_path("/path/to/the/file.ext")
8+
9+
# Parse the Cropper by passing the appropriate type
10+
result = input_doc.parse(documents.TypeCropperV1)
11+
12+
# Print a brief summary of the parsed data
13+
print(result.document)

docs/extras/code_samples/custom_v1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mindee_client = Client(api_key="my-api-key").add_endpoint(
77
)
88

99
# Load a file from disk and parse it.
10-
# The endpoint name must be specified since it can't be determined from the class.
10+
# The endpoint name must be specified since it cannot be determined from the class.
1111
result = mindee_client.doc_from_path(
1212
"/path/to/the/file.ext"
1313
).parse(documents.TypeCustomV1, endpoint_name="my-endpoint")
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)