mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-24 10:41:35 -04:00
Merge pull request #3185 from alphagov/set-crown-if-none-for-letter-rates
Quick fix for dealing with missing crown on a service sending letters
This commit is contained in:
@@ -455,6 +455,8 @@ def get_rate(
|
||||
if notification_type == LETTER_TYPE:
|
||||
if letter_page_count == 0:
|
||||
return 0
|
||||
# if crown is not set default to true, this is okay because the rates are the same for both crown and non-crown.
|
||||
crown = crown or True
|
||||
return next(
|
||||
r.rate
|
||||
for r in letter_rates if (
|
||||
|
||||
@@ -47,14 +47,14 @@ alembic==1.5.8
|
||||
amqp==1.4.9
|
||||
anyjson==0.3.3
|
||||
attrs==20.3.0
|
||||
awscli==1.19.35
|
||||
awscli==1.19.36
|
||||
bcrypt==3.2.0
|
||||
billiard==3.3.0.23
|
||||
bleach==3.3.0
|
||||
blinker==1.4
|
||||
boto==2.49.0
|
||||
boto3==1.17.35
|
||||
botocore==1.20.35
|
||||
boto3==1.17.36
|
||||
botocore==1.20.36
|
||||
certifi==2020.12.5
|
||||
chardet==4.0.0
|
||||
click==7.1.2
|
||||
@@ -66,6 +66,7 @@ geojson==2.5.0
|
||||
govuk-bank-holidays==0.8
|
||||
greenlet==1.0.0
|
||||
idna==2.10
|
||||
importlib-metadata==3.7.3
|
||||
Jinja2==2.11.3
|
||||
jmespath==0.10.0
|
||||
kombu==3.0.37
|
||||
@@ -87,13 +88,15 @@ pytz==2021.1
|
||||
PyYAML==5.4.1
|
||||
redis==3.5.3
|
||||
requests==2.25.1
|
||||
rsa==4.7.2
|
||||
rsa==4.5
|
||||
s3transfer==0.3.6
|
||||
Shapely==1.7.1
|
||||
six==1.15.0
|
||||
smartypants==2.0.1
|
||||
soupsieve==2.2.1
|
||||
statsd==3.3.0
|
||||
typing-extensions==3.7.4.3
|
||||
urllib3==1.26.4
|
||||
webencodings==0.5.1
|
||||
Werkzeug==1.0.1
|
||||
zipp==3.4.1
|
||||
|
||||
@@ -379,6 +379,17 @@ def test_get_rate_for_letter_latest(notify_db_session):
|
||||
assert rate == Decimal('0.33')
|
||||
|
||||
|
||||
def test_get_rate_for_letter_latest_if_crown_is_none(notify_db_session):
|
||||
# letter rates should be passed into the get_rate function as a tuple of start_date, crown, sheet_count,
|
||||
# rate and post_class
|
||||
crown = create_letter_rate(datetime(2017, 12, 1), crown=True, sheet_count=1, rate=0.33, post_class='second')
|
||||
non_crown = create_letter_rate(datetime(2017, 12, 1), crown=False, sheet_count=1, rate=0.35, post_class='second')
|
||||
letter_rates = [crown, non_crown]
|
||||
|
||||
rate = get_rate([], letter_rates, LETTER_TYPE, date(2018, 1, 1), crown=None, letter_page_count=1)
|
||||
assert rate == Decimal('0.33')
|
||||
|
||||
|
||||
def test_get_rate_for_sms_and_email(notify_db_session):
|
||||
non_letter_rates = [
|
||||
create_rate(datetime(2017, 12, 1), 0.15, SMS_TYPE),
|
||||
|
||||
Reference in New Issue
Block a user