-
Notifications
You must be signed in to change notification settings - Fork 4
Formidable schema test on yml #295
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
Conversation
18b17cd
to
aa2725f
Compare
02813f0
to
97a3521
Compare
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.
it seems to be good.
Also, I noticed that you have to use pytest in the requirements, how about to switch to it completely?
|
||
def test_wrong_type_fields_int(): | ||
form = _load_fixture('0010_wrong_type_field_int.json') | ||
errors = sorted(validator.iter_errors(form), key=lambda e: e.path) |
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.
This line occurs very often, have you considered a helper function to improve readability?
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.
now that you're mentioning it...
I'll see how I can improve this.
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.
mmmm... thinking about it, I'd be replacing one line of code by... one line of code & a function definition + one line of code... is it worth it?
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.
I was thinking this line is a bit "heavy" to read, and replacing it by a function call could make things clearer. But it definitely requires more code... Your call, the PR is approved 👍
@@ -0,0 +1,6 @@ | |||
{ |
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.
any reason the number in the file name goes from 0004 to 0010? (also some numbers are similar)
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.
I've tried to work using "blocks" of similar tests and "space" them to make sure I could squeeze more tests in the blocks without having to rename all my fixtures.
The numbers are following the schema definition logic, from the most basic to the most complicated.
On top of that, they haven't been written in order, I've jumped from one idea to another, so I've put "spaces" when I was starting to write a test that was a bit ahead, so sometimes there's a gap between fixture numbers.
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.
Thanks for the answer :)
this one was a bit different. I was just needing pure python tests, and nothing related to Django, so I didn't have to install pytest+pytest-django and try to configure this. But we may try to open this topic during the next technical grooming. |
This YAML file defines the accepted methods and formats for the form builder. It appeared that this is incomplete or obsolete and requires to be tested. As soon as something changes in this form definition, we should reflect it using a test that shows the impact. It is recommended to use the TDD method, by writing the test first and implement the change on your second move. The present test files are reflecting the spec *as it is written now* and will probably evolve as we'll fix them regarding the Python code that is supposed to implement this spec.
valid python 2.7 code is probably safe flake8-wise. It avoids hitting "syntax errors" when checking pure python3.6 test code.
97a3521
to
e8f6295
Compare
**Deprecation Warning**: The validation endpoint (using the URL ``forms/(?P<pk>\d+)/validate/``) is now ``POST`` only. - Added tests against the ``formidable.yml`` schema definition of Forms (#295). - Fixed various items in the schema definition (#297). - Validation endpoint for **user data** doesn't allow GET method anymore (#300). - Add support for multiple conditions to target a common field.
**Deprecation Warning**: The validation endpoint (using the URL ``forms/(?P<pk>\d+)/validate/``) is now ``POST`` only. - Added tests against the ``formidable.yml`` schema definition of Forms (#295). - Fixed various items in the schema definition (#297). - Validation endpoint for **user data** doesn't allow GET method anymore (#300). - Add support for multiple conditions to target a common field.
As you may see, this PR is establishing a set of basic tests on the Form schema, based on the
formidable.yml
file that lives in the documentation.From this perspective, I'm only testing it as-is, and I've added a certain number of "FIXME" tags to enhance this definition and fix it to synchronize it with the truth (ie.: the runtime code)
Review
CHANGELOG.rst
Updated