Migration to add international letter rates

New rows giving the prices of letters with a post_class of `europe` and
`rest-of-world` have been added to the `letter_rates` table. All rates
are currently the same for international letters.
This commit is contained in:
Katie Smith
2020-07-06 17:42:16 +01:00
parent fbdfa6416f
commit 5d47e1cf06
3 changed files with 101 additions and 9 deletions

View File

@@ -326,10 +326,12 @@ def test_get_rates_for_billing(notify_db_session):
create_rate(start_date=datetime.utcnow(), value=33, notification_type='email')
create_letter_rate(start_date=datetime.utcnow(), rate=0.66, post_class='first')
create_letter_rate(start_date=datetime.utcnow(), rate=0.33, post_class='second')
create_letter_rate(start_date=datetime.utcnow(), rate=0.84, post_class='europe')
create_letter_rate(start_date=datetime.utcnow(), rate=0.84, post_class='rest-of-world')
non_letter_rates, letter_rates = get_rates_for_billing()
assert len(non_letter_rates) == 3
assert len(letter_rates) == 2
assert len(letter_rates) == 4
@freeze_time('2017-06-01 12:00')
@@ -353,10 +355,17 @@ def test_get_rate(notify_db_session):
assert letter_rate == Decimal('0.3')
@pytest.mark.parametrize("letter_post_class,expected_rate", [("first", "0.61"), ("second", "0.35")])
@pytest.mark.parametrize("letter_post_class,expected_rate", [
("first", "0.61"),
("second", "0.35"),
("europe", "0.92"),
("rest-of-world", "1.05"),
])
def test_get_rate_filters_letters_by_post_class(notify_db_session, letter_post_class, expected_rate):
create_letter_rate(start_date=datetime(2017, 5, 30, 23, 0), sheet_count=2, rate=0.61, post_class='first')
create_letter_rate(start_date=datetime(2017, 5, 30, 23, 0), sheet_count=2, rate=0.35, post_class='second')
create_letter_rate(start_date=datetime(2017, 5, 30, 23, 0), sheet_count=2, rate=0.92, post_class='europe')
create_letter_rate(start_date=datetime(2017, 5, 30, 23, 0), sheet_count=2, rate=1.05, post_class='rest-of-world')
non_letter_rates, letter_rates = get_rates_for_billing()
rate = get_rate(non_letter_rates, letter_rates, "letter", datetime(2018, 10, 1), True, 2, letter_post_class)