forked from clan/clan-core
Added schemathesis dependency
This commit is contained in:
parent
798fbe3839
commit
32aa287da5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
.direnv
|
||||
***/.hypothesis
|
||||
.coverage.*
|
||||
**/qubeclan
|
||||
**/testdir
|
||||
|
@ -22,6 +22,11 @@ To implement property-based testing in FastAPI, you can use the following framew
|
||||
- [Schemathesis](https://schemathesis.readthedocs.io/en/stable/#id2)
|
||||
- [Hypothesis: Property-Based Testing](https://hypothesis.readthedocs.io/en/latest/quickstart.html)
|
||||
|
||||
|
||||
### Nix code
|
||||
https://github.com/kadena-io/signing-api/blob/master/schema-tests.nix
|
||||
https://github.com/garbas/cicero/blob/67acaaa6f568d6f5032419bdcf0f4c97fb46e5ec/pkgs/schemathesis.nix#L5
|
||||
|
||||
### Why Schemas Are Not Contracts
|
||||
|
||||
A schema is a description of the data structure of your API, whereas a contract defines not only the structure but also the expected behavior and constraints. The following resource explains why schemas are not contracts in more detail:
|
||||
@ -38,6 +43,8 @@ Contract-driven testing combines the benefits of type annotations and property-b
|
||||
|
||||
- Contracts, like property-based tests, allow you to specify conditions and constraints, with the testing framework automatically generating test cases and verifying call results.
|
||||
|
||||
|
||||
|
||||
### Frameworks for Contract-Driven Testing
|
||||
|
||||
To implement contract-driven testing in FastAPI, consider the following framework and extension:
|
||||
@ -46,3 +53,5 @@ To implement contract-driven testing in FastAPI, consider the following framewor
|
||||
- [FastAPI-iContract: Extension for FastAPI](https://github.com/mristin/fastapi-icontract)
|
||||
|
||||
By adopting contract-driven testing, you can ensure that your FastAPI application not only has a well-defined structure but also behaves correctly, making it more robust and reliable.
|
||||
|
||||
**However: icontract uses a 3 year old version of deal and a 3 year old version of typeguard. And icontract-fastapi is not maintained anymore**
|
@ -62,11 +62,11 @@
|
||||
},
|
||||
"luispkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1699286483,
|
||||
"narHash": "sha256-gzY56MbP3UTztI7Ra69RCNq81fKlsQu79LZ2gGss3Eg=",
|
||||
"lastModified": 1699386673,
|
||||
"narHash": "sha256-T9ZrVSf0ymSBHFpRw7K+DSNzY0sCkwkDe0VIzE033Ac=",
|
||||
"owner": "Luis-Hebendanz",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b59438a5a3b4d50e117081d41ed6f8833f65934d",
|
||||
"rev": "e918074d416f0918ac6c3895c6a5db2ae5ce3c1e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
|
||||
# https://github.com/NixOS/nixpkgs/pull/265872
|
||||
luispkgs.url = "github:Luis-Hebendanz/nixpkgs/fix_python_deal";
|
||||
|
||||
floco.url = "github:aakropotkin/floco";
|
||||
floco.inputs.nixpkgs.follows = "nixpkgs";
|
||||
disko.url = "github:nix-community/disko";
|
||||
@ -32,6 +33,7 @@
|
||||
"aarch64-darwin"
|
||||
];
|
||||
imports = [
|
||||
|
||||
./checks/flake-module.nix
|
||||
./devShell.nix
|
||||
./formatter.nix
|
||||
|
@ -34,8 +34,8 @@
|
||||
, gnupg
|
||||
, e2fsprogs
|
||||
, mypy
|
||||
, cntr
|
||||
, deal
|
||||
, schemathesis
|
||||
}:
|
||||
let
|
||||
|
||||
@ -58,6 +58,7 @@ let
|
||||
gnupg
|
||||
stdenv.cc
|
||||
deal
|
||||
schemathesis
|
||||
];
|
||||
|
||||
# Optional dependencies for clan cli, we re-expose them here to make sure they all build.
|
||||
|
@ -1,6 +1,10 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
perSystem = { self', pkgs, system, ... }: {
|
||||
perSystem = { self', pkgs, system, ... }:
|
||||
let
|
||||
luisPythonPkgs = inputs.luispkgs.legacyPackages.${system}.python3Packages;
|
||||
in
|
||||
{
|
||||
devShells.clan-cli = pkgs.callPackage ./shell.nix {
|
||||
inherit (self'.packages) clan-cli ui-assets nix-unit;
|
||||
};
|
||||
@ -8,7 +12,8 @@
|
||||
clan-cli = pkgs.python3.pkgs.callPackage ./default.nix {
|
||||
inherit (self'.packages) ui-assets;
|
||||
inherit (inputs) nixpkgs;
|
||||
deal = inputs.luispkgs.legacyPackages.${system}.python3Packages.deal;
|
||||
deal = luisPythonPkgs.deal;
|
||||
schemathesis = luisPythonPkgs.schemathesis;
|
||||
};
|
||||
inherit (self'.packages.clan-cli) clan-openapi;
|
||||
default = self'.packages.clan-cli;
|
||||
|
Loading…
Reference in New Issue
Block a user