Changed the update/insert to a postgres upsert to avoid concurrency issues.

This commit is contained in:
Rebecca Law
2018-05-15 11:21:10 +01:00
parent 3615f3d00f
commit 271ce6d76e
2 changed files with 56 additions and 25 deletions

View File

@@ -438,7 +438,22 @@ def test_create_nightly_billing_update_when_record_exists(
assert len(records) == 1
assert records[0].bst_date == date(2018, 1, 14)
assert records[0].billable_units == 1
sample_notification(
notify_db,
notify_db_session,
created_at=datetime.now() - timedelta(days=1),
service=sample_service,
template=sample_template,
status='delivered',
sent_by=None,
international=False,
rate_multiplier=1.0,
billable_units=1,
)
# run again, make sure create_nightly_billing() updates with no error
create_nightly_billing()
assert len(records) == 1
assert records[0].billable_units == 2