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
fix: handelled invalid price value in paid tickets #6604
Conversation
Codecov Report
@@ Coverage Diff @@
## development #6604 +/- ##
===============================================
- Coverage 65.03% 65.02% -0.01%
===============================================
Files 296 296
Lines 15247 15250 +3
===============================================
+ Hits 9916 9917 +1
- Misses 5331 5333 +2
Continue to review full report at Codecov.
|
@iamareebjamal @prateekj117 Please check |
app/api/schema/tickets.py
Outdated
@@ -67,6 +67,12 @@ def validate_quantity(self, data): | |||
raise UnprocessableEntity({'pointer': '/data/attributes/quantity'}, | |||
"quantity should be greater than or equal to max-order") | |||
|
|||
@validates_schema | |||
def validate_price(self, data): | |||
if data['type'] == 'paid' and ('price' not in data or not isinstance(data['price'], float)): |
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.
No need to check for the data type of data['price']
. Also, make sure that a paid ticket has a price > 0
.
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.
ok! adding the check
app/api/schema/tickets.py
Outdated
@@ -67,6 +67,12 @@ def validate_quantity(self, data): | |||
raise UnprocessableEntity({'pointer': '/data/attributes/quantity'}, | |||
"quantity should be greater than or equal to max-order") | |||
|
|||
@validates_schema | |||
def validate_price(self, data): | |||
if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0): |
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.
multiple spaces after keyword
app/api/schema/tickets.py
Outdated
def validate_price(self, data): | ||
if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0): | ||
raise UnprocessableEntity({'pointer': 'data/attributes/price'}, | ||
"paid ticket price should be valid") |
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.
"paid ticket price should be valid") | |
"paid ticket price should be greater than 0") |
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.
@iamareebjamal LGTM.
Thanks, I made it..! |
Fixes #6597
Short description of what this resolves:
Handles when price for paid ticket is null or not an instance of float value
Changes proposed in this pull request:
Checklist
development
branch.