-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fixes for single currency form, templatetags and tests refactoring #78
Conversation
4047390
to
3b947f9
Compare
assert 'name="price_1"' in result | ||
assert 'key="value"' in result | ||
assert 'value="5"' in result | ||
assert "USD" in result |
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.
Perhaps this could be tested with snapshot?
Also consider changing tests names to descriptive ones, eg test_money_input_widget_renders
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.
Not sure about adding snapshottest for one or two tests. I would say it's good enough
.
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.
# https://github.com/python-babel/babel/issues/30 | ||
translation.activate("oO_Oo") | ||
amount = prices_i18n.amount(money_fixture, format="html") | ||
assert amount # No exception, success! |
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 is a noop. It does not test anything as any exception would be raised in the previous line. Why don't you instead document what the result should be with a snapshot?
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'm not the original author of this test
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.
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.
Since we now explicitly depend on Babel, I don't think it makes sense to support the non-i18n-aware version of the template tags. Can we move the i18n ones to prices
and have prices_i18n
call the ones from prices
with a deprecation warning?
if amount in self.empty_values and self.required: | ||
raise ValidationError("Enter a valid amount of money") | ||
if currency in self.empty_values and self.required: | ||
raise ValidationError("Enter a valid currency code") |
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.
Do users enter a currency code?
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 believe it's for those who use custom widgets.
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'm asking about the wording: "Enter a valid currency code" vs "Select a valid currency" as the currency is unlikely to be something entered (typed into the field) directly.
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 occurs when somebody uses fixed currency form and submits (by example using curl) intentionally different value.
Currency Field in multicurrency form has its own validation.
pattern = locale.currency_formats.get("standard").pattern | ||
|
||
if html: | ||
pattern = re.sub("(\xa4+)", '<span class="currency">\\1</span>', pattern) |
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.
Maybe-ish putting the currency code somewhere in there may be useful? data-currency="USD"
.
ffbf158
to
3187cc3
Compare
Co-Authored-By: Rafał Pitoń <[email protected]>
Co-Authored-By: Adam Bogdał <[email protected]>
3187cc3
to
6ca2c88
Compare
@patrys Rebased! Can be released as alpha 🎉 |
Updated:
None
is returned