Merge branch 'master' into sms_sender_id-for-post-notfications

This commit is contained in:
Rebecca Law
2017-10-30 15:20:39 +00:00
14 changed files with 426 additions and 29 deletions

View File

@@ -37,6 +37,7 @@ from tests.app.db import (
create_service_sms_sender
)
from tests.app.db import create_user
from app.service.utils import get_current_financial_year_start_year
def test_get_service_list(client, service_factory):
@@ -300,6 +301,7 @@ def test_create_service(client, sample_user):
assert not json_resp['data']['research_mode']
assert json_resp['data']['dvla_organisation'] == '001'
assert json_resp['data']['sms_sender'] == current_app.config['FROM_NUMBER']
# TODO: Remove this after the new data is used
assert json_resp['data']['free_sms_fragment_limit'] == current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT']
service_db = Service.query.get(json_resp['data']['id'])
@@ -365,6 +367,15 @@ def test_create_service_free_sms_fragment_limit_is_optional(client, sample_user)
headers=headers)
json_resp = json.loads(resp.get_data(as_text=True))
assert resp.status_code == 201
# Test data from the new annual billing table
service_id = json_resp['data']['id']
annual_billing = client.get('service/{}/billing/free-sms-fragment-limit?financial_year_start={}'
.format(service_id, get_current_financial_year_start_year()),
headers=[('Content-Type', 'application/json'), create_authorization_header()])
json_resp = json.loads(annual_billing.get_data(as_text=True))
assert json_resp['data']['free_sms_fragment_limit'] == 9999
# TODO: Remove this after the new data is used
assert json_resp['data']['free_sms_fragment_limit'] == 9999
data2 = {
@@ -385,6 +396,14 @@ def test_create_service_free_sms_fragment_limit_is_optional(client, sample_user)
headers=headers)
json_resp = json.loads(resp.get_data(as_text=True))
assert resp.status_code == 201
# Test data from the new annual billing table
service_id = json_resp['data']['id']
annual_billing = client.get('service/{}/billing/free-sms-fragment-limit?financial_year_start={}'
.format(service_id, get_current_financial_year_start_year()),
headers=[('Content-Type', 'application/json'), create_authorization_header()])
json_resp = json.loads(annual_billing.get_data(as_text=True))
assert json_resp['data']['free_sms_fragment_limit'] == current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT']
# TODO: Remove this after the new data is used
assert json_resp['data']['free_sms_fragment_limit'] == current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT']
@@ -623,6 +642,7 @@ def test_update_service_flags_will_remove_service_permissions(client, notify_db,
assert set([p.permission for p in permissions]) == set([SMS_TYPE, EMAIL_TYPE])
# TODO: Remove after new table is created and verified
def test_update_service_free_sms_fragment_limit(client, notify_db, sample_service):
org = Organisation(colour='#000000', logo='justice-league.png', name='Justice League')
notify_db.session.add(org)

View File

@@ -0,0 +1,15 @@
from app.service.utils import get_current_financial_year_start_year
from freezegun import freeze_time
# see get_financial_year for conversion of financial years.
@freeze_time("2017-03-31 22:59:59.999999")
def test_get_current_financial_year_start_year_before_march():
current_fy = get_current_financial_year_start_year()
assert current_fy == 2016
@freeze_time("2017-03-31 23:00:00.000000")
def test_get_current_financial_year_start_year_after_april():
current_fy = get_current_financial_year_start_year()
assert current_fy == 2017