-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added json schema to validate query params, added unit tests (#4)
* feat: query tests added * feat: added test query for in/nin with numbers * feat: added json schema to validate query params, added unit tests * feat: added select fields validation
- Loading branch information
Showing
7 changed files
with
1,023 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python package | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install poetry | ||
python -m poetry install | ||
- name: Test with pytest | ||
run: | | ||
python -m poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "ENAC-IT4R Python SQL Utils: Query Schema", | ||
"type": "object", | ||
"properties": { | ||
"filter": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{ "$ref": "#/definitions/condition" }, | ||
{ "type": "number" }, | ||
{ "type": "string" }, | ||
{ | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/condition" } | ||
} | ||
] | ||
} | ||
}, | ||
"sort": { | ||
"type": "array", | ||
"items": [ | ||
{ "type": "string" }, | ||
{ "type": "string", "enum": ["ASC", "DESC", "asc", "desc"], "default": "ASC" } | ||
], | ||
"minItems": 0, | ||
"maxItems": 2 | ||
}, | ||
"range": { | ||
"type": "array", | ||
"items": { "type": "integer" }, | ||
"minItems": 0, | ||
"maxItems": 2 | ||
}, | ||
"fields": { | ||
"type": "array", | ||
"items": { "type": "string" }, | ||
"minItems": 0 | ||
} | ||
}, | ||
"definitions": { | ||
"condition": { | ||
"type": "object", | ||
"anyOf": [ | ||
{ | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/condition" } | ||
}, | ||
{ | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{ "$ref": "#/definitions/condition" }, | ||
{ | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/condition" } | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$eq": { "type": ["string", "number"] } | ||
}, | ||
"required": ["$eq"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$ne": { "type": ["string", "number"] } | ||
}, | ||
"required": ["$ne"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$lt": { "type": "number" } | ||
}, | ||
"required": ["$lt"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$lte": { "type": "number" } | ||
}, | ||
"required": ["$lte"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$le": { "type": "number" } | ||
}, | ||
"required": ["$le"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$gt": { "type": "number" } | ||
}, | ||
"required": ["$gt"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$gte": { "type": "number" } | ||
}, | ||
"required": ["$gte"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$ge": { "type": "number" } | ||
}, | ||
"required": ["$ge"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$ilike": { "type": "string" } | ||
}, | ||
"required": ["$ilike"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$like": { "type": "string" } | ||
}, | ||
"required": ["$like"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$contains": { | ||
"type": "array", | ||
"items": { "type": ["string", "number"] } | ||
} | ||
}, | ||
"required": ["$contains"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$in": { | ||
"type": "array", | ||
"items": { "type": ["string", "number"] } | ||
} | ||
}, | ||
"required": ["$in"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$nin": { | ||
"type": "array", | ||
"items": { "type": ["string", "number"] } | ||
} | ||
}, | ||
"required": ["$nin"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"$exists": { "type": "boolean" } | ||
}, | ||
"required": ["$exists"] | ||
} | ||
] | ||
} | ||
}, | ||
"required": ["filter"], | ||
"additionalProperties": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.