-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add semantic model test to test_contracts_graph_parsed.py
#8654
Add semantic model test to test_contracts_graph_parsed.py
#8654
Conversation
The tests in `test_contracts_graph_parsed.py` are meant to ensure that we can go from objects to dictionaries and back without any changes. We've had a desire to simplify these tests. Most tests in this file have three to four fixtures, this test only has one. What a test of this format ensures is that parsing a SemanticModel from a dictionary doesn't add/drop any keys from the dictionary and that when going back to the dictionary no keys are dropped. This style of test will still break whenever the semantic model (or sub objects) change. However now when that happens, only one fixture will have to be updated (whereas previously we had to update 3-4 fixtures).
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8654 +/- ##
==========================================
- Coverage 86.60% 86.50% -0.10%
==========================================
Files 175 176 +1
Lines 25638 25856 +218
==========================================
+ Hits 22204 22368 +164
- Misses 3434 3488 +54
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Hypothesis is a python package for doing property testing. The `@given` parameterizes a test, with it generating the arguements it has following `strategies`. The main strategies we use is `builds` this takes in a callable passes any sub strategies for named arguements, and will try to infer any other arguments if the callable is typed. I found that even though the test was run many many times, some of the `SemanticModel` properties weren't being changed. For instance `dimensions`, `entities`, and `measures` were always empty lists. Because of this I defined sub strategies for some attributes of `SemanticModel`s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some info to the existing README (that's empty...) about when we generally want to use hypothesis?
resolves #8139
Problem
The tests in
test_contracts_graph_parsed.py
are meant to ensure that we can go from objects to dictionaries and back without any changes. There are two problems this PR aims to solveSolution
We added a test for semantic models symmetry. The test depends on a new package
hypothesis
. The@given
parameterizes a test, with it generating the arguements it has followingstrategies
. The main strategies we use isbuilds
this takes in a callable passes any sub strategies for named arguements, and will try to infer any other arguments if the callable is typed. I found that even though the test was run many many times, some of theSemanticModel
properties weren't being changed. For instancedimensions
,entities
, andmeasures
were always empty lists. Because of this I defined sub strategies for some attributes ofSemanticModel
s.Checklist