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

Filters on API operations #1256

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Filters on API operations #1256

wants to merge 4 commits into from

Conversation

Stranger6667
Copy link
Member

@Stranger6667 Stranger6667 commented Aug 30, 2021

Resolves #703
Resolves #819
Resolves #1006

TODO:

  • Deprecation docs
  • Deprecate passing filters to loaders
  • Deprecate passing filters to parametrize
  • Use include in tests
  • Deprecate using old CLI arguments for filtration
  • Make CLI use include / exclude
  • CLI support for custom filters. It could be some simple jq-like filter - --include-by="x-foo == 42", where the expression is of form "JSONPath Operator Value"
  • CLI support for new filters - --include-method, --exclude-method, etc.
  • How to remove filters?
  • Implement exclude
  • Add include / exclude for GraphQL schemas
  • Add relevant methods on "lazy" schemas
  • Docs (CLI & Python) & comments
  • Use path instead endpoint?
  • Separate method for regular expressions?
  • How to deal with lists of strings?
  • Better repr for filter functions
  • Deal with filters overriding

In Schemathesis 4.0 it will be nice to remove those arguments & attributes

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2021

Codecov Report

Merging #1256 (15af684) into master (6987f7b) will decrease coverage by 0.26%.
The diff coverage is 92.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1256      +/-   ##
==========================================
- Coverage   99.41%   99.15%   -0.27%     
==========================================
  Files          82       83       +1     
  Lines        6152     6250      +98     
  Branches     1016     1043      +27     
==========================================
+ Hits         6116     6197      +81     
- Misses         18       30      +12     
- Partials       18       23       +5     
Flag Coverage Δ
unittests 99.12% <92.03%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/schemathesis/filters.py 88.63% <88.63%> (ø)
src/schemathesis/schemas.py 98.36% <90.90%> (-1.03%) ⬇️
src/schemathesis/specs/openapi/schemas.py 99.53% <91.66%> (-0.47%) ⬇️
src/schemathesis/hooks.py 100.00% <100.00%> (ø)
src/schemathesis/lazy.py 95.49% <100.00%> (+0.16%) ⬆️
src/schemathesis/models.py 99.20% <100.00%> (ø)
src/schemathesis/runner/__init__.py 97.33% <100.00%> (ø)
src/schemathesis/specs/openapi/loaders.py 100.00% <100.00%> (ø)
src/schemathesis/utils.py 99.06% <100.00%> (+<0.01%) ⬆️
src/schemathesis/specs/openapi/filters.py 74.19% <0.00%> (-25.81%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6987f7b...15af684. Read the comment docs.

return self._filter_by(Exclude(predicate))

def _filter_by(self, *predicates: BaseFilter) -> S:
filters = self.filters + list(predicates)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have a way to combine filters via OR

@Stranger6667 Stranger6667 force-pushed the dd/filter-operations branch 2 times, most recently from 74318c6 to 15af684 Compare September 29, 2021 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants