From 3fff0fdd8434db00a03cefc0475c6d497ab49225 Mon Sep 17 00:00:00 2001 From: stvnrlly Date: Mon, 17 Oct 2022 20:16:39 +0000 Subject: [PATCH] remove crown stuff --- app/commands.py | 20 ++++--- app/dao/broadcast_service_dao.py | 1 - app/dao/fact_billing_dao.py | 14 +++-- app/dao/organisation_dao.py | 4 -- app/dao/services_dao.py | 2 - app/models.py | 5 -- app/notifications/validators.py | 5 +- app/organisation/organisation_schema.py | 4 +- app/organisation/rest.py | 1 + app/schemas.py | 2 - .../versions/0306_letter_rates_price_rise.py | 54 ++++++++++--------- migrations/versions/0324_int_letter_rates.py | 40 +++++++------- migrations/versions/0341_new_letter_rates.py | 46 ++++++++-------- migrations/versions/0366_letter_rates_2022.py | 46 ++++++++-------- migrations/versions/0379_remove_crown.py | 33 ++++++++++++ tests/app/celery/test_reporting_tasks.py | 19 +++---- tests/app/conftest.py | 5 +- tests/app/dao/test_fact_billing_dao.py | 6 +-- tests/app/dao/test_organisation_dao.py | 17 ------ tests/app/dao/test_services_dao.py | 2 - tests/app/db.py | 5 +- tests/app/organisation/test_rest.py | 32 +---------- 22 files changed, 168 insertions(+), 195 deletions(-) create mode 100644 migrations/versions/0379_remove_crown.py diff --git a/app/commands.py b/app/commands.py index 0515a755f..a24245e25 100644 --- a/app/commands.py +++ b/app/commands.py @@ -459,15 +459,14 @@ def replay_daily_sorted_count_files(file_extension): @notify_command(name='populate-organisations-from-file') @click.option('-f', '--file_name', required=True, - help="Pipe delimited file containing organisation name, sector, crown, argeement_signed, domains") + help="Pipe delimited file containing organisation name, sector, argeement_signed, domains") def populate_organisations_from_file(file_name): # [0] organisation name:: name of the organisation insert if organisation is missing. # [1] sector:: Federal | State only - # [2] crown:: TRUE | FALSE only - # [3] argeement_signed:: TRUE | FALSE - # [4] domains:: comma separated list of domains related to the organisation - # [5] email branding name: name of the default email branding for the org - # [6] letter branding name: name of the default letter branding for the org + # [2] argeement_signed:: TRUE | FALSE + # [3] domains:: comma separated list of domains related to the organisation + # [4] email branding name: name of the default email branding for the org + # [5] letter branding name: name of the default letter branding for the org # The expectation is that the organisation, organisation_to_service # and user_to_organisation will be cleared before running this command. @@ -485,18 +484,17 @@ def populate_organisations_from_file(file_name): columns = line.split('|') print(columns) email_branding = None - email_branding_column = columns[5].strip() + email_branding_column = columns[4].strip() if len(email_branding_column) > 0: email_branding = EmailBranding.query.filter(EmailBranding.name == email_branding_column).one() letter_branding = None - letter_branding_column = columns[6].strip() + letter_branding_column = columns[5].strip() if len(letter_branding_column) > 0: letter_branding = LetterBranding.query.filter(LetterBranding.name == letter_branding_column).one() data = { 'name': columns[0], 'active': True, - 'agreement_signed': boolean_or_none(columns[3]), - 'crown': boolean_or_none(columns[2]), + 'agreement_signed': boolean_or_none(columns[2]), 'organisation_type': columns[1].lower(), 'email_branding_id': email_branding.id if email_branding else None, 'letter_branding_id': letter_branding.id if letter_branding else None @@ -509,7 +507,7 @@ def populate_organisations_from_file(file_name): except IntegrityError: print("duplicate org", org.name) db.session.rollback() - domains = columns[4].split(',') + domains = columns[3].split(',') for d in domains: if len(d.strip()) > 0: domain = Domain(domain=d.strip(), organisation_id=org.id) diff --git a/app/dao/broadcast_service_dao.py b/app/dao/broadcast_service_dao.py index 6166b0634..2cf34bdd2 100644 --- a/app/dao/broadcast_service_dao.py +++ b/app/dao/broadcast_service_dao.py @@ -82,7 +82,6 @@ def set_broadcast_service_type(service, service_mode, broadcast_channel, provide ).one() service.organisation_id = organisation.id service.organisation_type = organisation.organisation_type - service.crown = organisation.crown db.session.add(service) diff --git a/app/dao/fact_billing_dao.py b/app/dao/fact_billing_dao.py index 3ba2289cf..7c2fae2a7 100644 --- a/app/dao/fact_billing_dao.py +++ b/app/dao/fact_billing_dao.py @@ -470,7 +470,6 @@ def _query_for_billing_data(notification_type, start_date, end_date, service): def _email_query(): return db.session.query( NotificationAllTimeView.template_id, - literal(service.crown).label('crown'), literal(service.id).label('service_id'), literal(notification_type).label('notification_type'), literal('ses').label('sent_by'), @@ -497,7 +496,6 @@ def _query_for_billing_data(notification_type, start_date, end_date, service): international = func.coalesce(NotificationAllTimeView.international, False) return db.session.query( NotificationAllTimeView.template_id, - literal(service.crown).label('crown'), literal(service.id).label('service_id'), literal(notification_type).label('notification_type'), sent_by.label('sent_by'), @@ -526,7 +524,6 @@ def _query_for_billing_data(notification_type, start_date, end_date, service): postage = func.coalesce(NotificationAllTimeView.postage, 'none') return db.session.query( NotificationAllTimeView.template_id, - literal(service.crown).label('crown'), literal(service.id).label('service_id'), literal(notification_type).label('notification_type'), literal('dvla').label('sent_by'), @@ -579,20 +576,22 @@ def get_service_ids_that_need_billing_populated(start_date, end_date): def get_rate( - non_letter_rates, letter_rates, notification_type, date, crown=None, letter_page_count=None, post_class='second' + non_letter_rates, + letter_rates, + notification_type, + date, + letter_page_count=None, + post_class='second' ): start_of_day = get_london_midnight_in_utc(date) 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 ( start_of_day >= r.start_date and - crown == r.crown and letter_page_count == r.sheet_count and post_class == r.post_class ) @@ -615,7 +614,6 @@ def update_fact_billing(data, process_day): letter_rates, data.notification_type, process_day, - data.crown, data.letter_page_count, data.postage) billing_record = create_billing_record(data, rate, process_day) diff --git a/app/dao/organisation_dao.py b/app/dao/organisation_dao.py index 198f1e30a..b0b11cb00 100644 --- a/app/dao/organisation_dao.py +++ b/app/dao/organisation_dao.py @@ -83,9 +83,6 @@ def dao_update_organisation(organisation_id, **kwargs): if 'organisation_type' in kwargs: _update_organisation_services(organisation, 'organisation_type', only_where_none=False) - if 'crown' in kwargs: - _update_organisation_services(organisation, 'crown', only_where_none=False) - if 'email_branding_id' in kwargs: _update_organisation_services(organisation, 'email_branding') @@ -114,7 +111,6 @@ def dao_add_service_to_organisation(service, organisation_id): service.organisation_id = organisation_id service.organisation_type = organisation.organisation_type - service.crown = organisation.crown db.session.add(service) diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index f8c60272f..0debffbeb 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -321,8 +321,6 @@ def dao_create_service( if organisation.letter_branding: service.letter_branding = organisation.letter_branding - if organisation: - service.crown = organisation.crown service.count_as_live = not user.platform_admin db.session.add(service) diff --git a/app/models.py b/app/models.py index ed37aa9cc..724f6db03 100644 --- a/app/models.py +++ b/app/models.py @@ -360,7 +360,6 @@ class OrganisationTypes(db.Model): __tablename__ = 'organisation_types' name = db.Column(db.String(255), primary_key=True) - is_crown = db.Column(db.Boolean, nullable=True) annual_free_sms_fragment_limit = db.Column(db.BigInteger, nullable=False) @@ -382,7 +381,6 @@ class Organisation(db.Model): agreement_signed_on_behalf_of_name = db.Column(db.String(255), nullable=True) agreement_signed_on_behalf_of_email_address = db.Column(db.String(255), nullable=True) agreement_signed_version = db.Column(db.Float, nullable=True) - crown = db.Column(db.Boolean, nullable=True) organisation_type = db.Column( db.String(255), db.ForeignKey('organisation_types.name'), @@ -433,7 +431,6 @@ class Organisation(db.Model): "id": str(self.id), "name": self.name, "active": self.active, - "crown": self.crown, "organisation_type": self.organisation_type, "letter_branding_id": self.letter_branding_id, "email_branding_id": self.email_branding_id, @@ -495,7 +492,6 @@ class Service(db.Model, Versioned): unique=False, nullable=True, ) - crown = db.Column(db.Boolean, index=False, nullable=True) rate_limit = db.Column(db.Integer, index=False, nullable=False, default=3000) contact_link = db.Column(db.String(255), nullable=True, unique=False) volume_sms = db.Column(db.Integer(), nullable=True, unique=False) @@ -2022,7 +2018,6 @@ class LetterRate(db.Model): end_date = db.Column(db.DateTime, nullable=True) sheet_count = db.Column(db.Integer, nullable=False) # double sided sheet rate = db.Column(db.Numeric(), nullable=False) - crown = db.Column(db.Boolean, nullable=False) post_class = db.Column(db.String, nullable=False) diff --git a/app/notifications/validators.py b/app/notifications/validators.py index 03a98b812..f5b76948c 100644 --- a/app/notifications/validators.py +++ b/app/notifications/validators.py @@ -151,10 +151,7 @@ def check_if_service_can_send_to_number(service, number): else: permissions = service.permissions - if ( - # if number is international and not a crown dependency - international_phone_info.international and not international_phone_info.crown_dependency - ) and INTERNATIONAL_SMS_TYPE not in permissions: + if (international_phone_info.international) and INTERNATIONAL_SMS_TYPE not in permissions: raise BadRequestError(message="Cannot send to international mobile numbers") else: return international_phone_info diff --git a/app/organisation/organisation_schema.py b/app/organisation/organisation_schema.py index acc90d42d..bfdec6df1 100644 --- a/app/organisation/organisation_schema.py +++ b/app/organisation/organisation_schema.py @@ -8,10 +8,9 @@ post_create_organisation_schema = { "properties": { "name": {"type": "string"}, "active": {"type": ["boolean", "null"]}, - "crown": {"type": "boolean"}, "organisation_type": {"enum": ORGANISATION_TYPES}, }, - "required": ["name", "crown", "organisation_type"] + "required": ["name", "organisation_type"] } post_update_organisation_schema = { @@ -21,7 +20,6 @@ post_update_organisation_schema = { "properties": { "name": {"type": ["string", "null"]}, "active": {"type": ["boolean", "null"]}, - "crown": {"type": ["boolean", "null"]}, "organisation_type": {"enum": ORGANISATION_TYPES}, }, "required": [] diff --git a/app/organisation/rest.py b/app/organisation/rest.py index a44cb8b9c..0df9040c0 100644 --- a/app/organisation/rest.py +++ b/app/organisation/rest.py @@ -211,6 +211,7 @@ def send_notifications_on_mou_signed(organisation_id): send_notification_to_queue(saved_notification, research_mode=False, queue=QueueNames.NOTIFY) personalisation = { + # TODO: needs an approach detached from crown binary 'mou_link': '{}/agreement/{}.pdf'.format( current_app.config['ADMIN_BASE_URL'], 'crown' if organisation.crown else 'non-crown' diff --git a/app/schemas.py b/app/schemas.py index 5fc97bb7c..4994fcdd8 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -274,7 +274,6 @@ class ServiceSchema(BaseSchema, UUIDsAsStringsMixin): 'complaints', 'contact_list', 'created_at', - 'crown', 'data_retention', 'guest_list', 'inbound_number', @@ -334,7 +333,6 @@ class DetailedServiceSchema(BaseSchema): 'broadcast_messages', 'contact_list', 'created_by', - 'crown', 'email_branding', 'email_from', 'guest_list', diff --git a/migrations/versions/0306_letter_rates_price_rise.py b/migrations/versions/0306_letter_rates_price_rise.py index 892b0b7c3..a04692c0d 100644 --- a/migrations/versions/0306_letter_rates_price_rise.py +++ b/migrations/versions/0306_letter_rates_price_rise.py @@ -38,33 +38,37 @@ CHANGEOVER_DATE = datetime(2019, 9, 30, 23, 0) def upgrade(): # all old rates are going in the bin - conn = op.get_bind() - conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE) + # conn = op.get_bind() + # conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE) - base_prices = { - 'second': 30, - 'first': 56, - } - op.bulk_insert(LetterRate.__table__, [ - { - 'id': uuid.uuid4(), - 'start_date': CHANGEOVER_DATE, - 'end_date': None, - 'sheet_count': sheet_count, - 'rate': (base_prices[post_class] + (5 * sheet_count)) / 100.0, - 'crown': crown, - 'post_class': post_class, - } - for sheet_count, crown, post_class in itertools.product( - range(1, 6), - [True, False], - ['first', 'second'] - ) - ]) + # base_prices = { + # 'second': 30, + # 'first': 56, + # } + # op.bulk_insert(LetterRate.__table__, [ + # { + # 'id': uuid.uuid4(), + # 'start_date': CHANGEOVER_DATE, + # 'end_date': None, + # 'sheet_count': sheet_count, + # 'rate': (base_prices[post_class] + (5 * sheet_count)) / 100.0, + # 'crown': crown, + # 'post_class': post_class, + # } + # for sheet_count, crown, post_class in itertools.product( + # range(1, 6), + # [True, False], + # ['first', 'second'] + # ) + # ]) + + pass def downgrade(): # Make sure you've thought about billing implications etc before downgrading! - conn = op.get_bind() - conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE) - conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE) + # conn = op.get_bind() + # conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE) + # conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE) + + pass \ No newline at end of file diff --git a/migrations/versions/0324_int_letter_rates.py b/migrations/versions/0324_int_letter_rates.py index 59cf140ba..60ea637f4 100644 --- a/migrations/versions/0324_int_letter_rates.py +++ b/migrations/versions/0324_int_letter_rates.py @@ -31,24 +31,28 @@ def upgrade(): 4 sheets - £1.08 5 sheets - £1.16 """ - op.bulk_insert(LetterRate.__table__, [ - { - 'id': uuid.uuid4(), - 'start_date': start_date, - 'end_date': None, - 'sheet_count': sheet_count, - 'rate': (base_rate + (8 * sheet_count)) / 100.0, - 'crown': crown, - 'post_class': post_class, - } - for sheet_count, crown, post_class in itertools.product( - range(1, 6), - [True, False], - ['europe', 'rest-of-world'] - ) - ]) + # op.bulk_insert(LetterRate.__table__, [ + # { + # 'id': uuid.uuid4(), + # 'start_date': start_date, + # 'end_date': None, + # 'sheet_count': sheet_count, + # 'rate': (base_rate + (8 * sheet_count)) / 100.0, + # 'crown': crown, + # 'post_class': post_class, + # } + # for sheet_count, crown, post_class in itertools.product( + # range(1, 6), + # [True, False], + # ['europe', 'rest-of-world'] + # ) + # ]) + + pass def downgrade(): - conn = op.get_bind() - conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=start_date) + # conn = op.get_bind() + # conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=start_date) + + pass diff --git a/migrations/versions/0341_new_letter_rates.py b/migrations/versions/0341_new_letter_rates.py index cac72c6fe..3fad31156 100644 --- a/migrations/versions/0341_new_letter_rates.py +++ b/migrations/versions/0341_new_letter_rates.py @@ -35,28 +35,32 @@ def get_new_rate(sheet_count, post_class): def upgrade(): - conn = op.get_bind() - conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE) + # conn = op.get_bind() + # conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE) - op.bulk_insert(LetterRate.__table__, [ - { - 'id': uuid.uuid4(), - 'start_date': CHANGEOVER_DATE, - 'end_date': None, - 'sheet_count': sheet_count, - 'rate': get_new_rate(sheet_count, post_class), - 'crown': crown, - 'post_class': post_class, - } - for sheet_count, crown, post_class in itertools.product( - range(1, 6), - [True, False], - ['first', 'second', 'europe', 'rest-of-world'] - ) - ]) + # op.bulk_insert(LetterRate.__table__, [ + # { + # 'id': uuid.uuid4(), + # 'start_date': CHANGEOVER_DATE, + # 'end_date': None, + # 'sheet_count': sheet_count, + # 'rate': get_new_rate(sheet_count, post_class), + # 'crown': crown, + # 'post_class': post_class, + # } + # for sheet_count, crown, post_class in itertools.product( + # range(1, 6), + # [True, False], + # ['first', 'second', 'europe', 'rest-of-world'] + # ) + # ]) + + pass def downgrade(): # Make sure you've thought about billing implications etc before downgrading! - conn = op.get_bind() - conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE) - conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE) + # conn = op.get_bind() + # conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE) + # conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE) + + pass diff --git a/migrations/versions/0366_letter_rates_2022.py b/migrations/versions/0366_letter_rates_2022.py index 80bb5ef20..ecf845b49 100644 --- a/migrations/versions/0366_letter_rates_2022.py +++ b/migrations/versions/0366_letter_rates_2022.py @@ -35,29 +35,33 @@ def get_new_rate(sheet_count, post_class): def upgrade(): - conn = op.get_bind() - conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE) + # conn = op.get_bind() + # conn.execute(text("UPDATE letter_rates SET end_date = :start WHERE end_date IS NULL"), start=CHANGEOVER_DATE) - op.bulk_insert(LetterRate.__table__, [ - { - 'id': uuid.uuid4(), - 'start_date': CHANGEOVER_DATE, - 'end_date': None, - 'sheet_count': sheet_count, - 'rate': get_new_rate(sheet_count, post_class), - 'crown': crown, - 'post_class': post_class, - } - for sheet_count, crown, post_class in itertools.product( - range(1, 6), - [True, False], - ['first', 'second', 'europe', 'rest-of-world'] - ) - ]) + # op.bulk_insert(LetterRate.__table__, [ + # { + # 'id': uuid.uuid4(), + # 'start_date': CHANGEOVER_DATE, + # 'end_date': None, + # 'sheet_count': sheet_count, + # 'rate': get_new_rate(sheet_count, post_class), + # 'crown': crown, + # 'post_class': post_class, + # } + # for sheet_count, crown, post_class in itertools.product( + # range(1, 6), + # [True, False], + # ['first', 'second', 'europe', 'rest-of-world'] + # ) + # ]) + + pass def downgrade(): # Make sure you've thought about billing implications etc before downgrading! - conn = op.get_bind() - conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE) - conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE) + # conn = op.get_bind() + # conn.execute(text("DELETE FROM letter_rates WHERE start_date = :start"), start=CHANGEOVER_DATE) + # conn.execute(text("UPDATE letter_rates SET end_date = NULL WHERE end_date = :start"), start=CHANGEOVER_DATE) + + pass diff --git a/migrations/versions/0379_remove_crown.py b/migrations/versions/0379_remove_crown.py new file mode 100644 index 000000000..ede9b2060 --- /dev/null +++ b/migrations/versions/0379_remove_crown.py @@ -0,0 +1,33 @@ +""" + +Revision ID: 0379_remove_crown +Revises: 0378_add_org_names +Create Date: 2022-10-17 17:05:07.193377 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0379_remove_crown' +down_revision = '0378_add_org_names' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('letter_rates', 'crown') + op.drop_column('organisation', 'crown') + op.drop_column('organisation_types', 'is_crown') + op.drop_column('services', 'crown') + op.drop_column('services_history', 'crown') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('services_history', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('services', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('organisation_types', sa.Column('is_crown', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('organisation', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('letter_rates', sa.Column('crown', sa.BOOLEAN(), autoincrement=False, nullable=False)) + # ### end Alembic commands ### diff --git a/tests/app/celery/test_reporting_tasks.py b/tests/app/celery/test_reporting_tasks.py index e4f0db279..172471e54 100644 --- a/tests/app/celery/test_reporting_tasks.py +++ b/tests/app/celery/test_reporting_tasks.py @@ -36,7 +36,7 @@ from tests.app.db import ( def mocker_get_rate( - non_letter_rates, letter_rates, notification_type, bst_date, crown=None, rate_multiplier=None, post_class="second" + non_letter_rates, letter_rates, notification_type, bst_date, rate_multiplier=None, post_class="second" ): if notification_type == LETTER_TYPE: return Decimal(2.1) @@ -436,24 +436,25 @@ def test_create_nightly_billing_for_day_null_sent_by_sms( def test_get_rate_for_letter_latest(notify_db_session): - # letter rates should be passed into the get_rate function as a tuple of start_date, crown, sheet_count, + # letter rates should be passed into the get_rate function as a tuple of start_date, sheet_count, # rate and post_class - new = create_letter_rate(datetime(2017, 12, 1), crown=True, sheet_count=1, rate=0.33, post_class='second') - old = create_letter_rate(datetime(2016, 12, 1), crown=True, sheet_count=1, rate=0.30, post_class='second') + new = create_letter_rate(datetime(2017, 12, 1), sheet_count=1, rate=0.33, post_class='second') + old = create_letter_rate(datetime(2016, 12, 1), sheet_count=1, rate=0.30, post_class='second') letter_rates = [new, old] - rate = get_rate([], letter_rates, LETTER_TYPE, date(2018, 1, 1), True, 1) + rate = get_rate([], letter_rates, LETTER_TYPE, date(2018, 1, 1), 1) 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, + # letter rates should be passed into the get_rate function as a tuple of start_date, 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') + # this might still work if crown is removed??? + crown = create_letter_rate(datetime(2017, 12, 1), sheet_count=1, rate=0.33, post_class='second') + non_crown = create_letter_rate(datetime(2017, 12, 1), 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) + rate = get_rate([], letter_rates, LETTER_TYPE, date(2018, 1, 1), letter_page_count=1) assert rate == Decimal('0.33') diff --git a/tests/app/conftest.py b/tests/app/conftest.py index f68afb94f..1b82cacf1 100644 --- a/tests/app/conftest.py +++ b/tests/app/conftest.py @@ -223,7 +223,6 @@ def sample_service(sample_user): 'restricted': False, 'email_from': email_from, 'created_by': sample_user, - 'crown': True } service = Service.query.filter_by(name=service_name).first() if not service: @@ -247,7 +246,6 @@ def sample_broadcast_service(broadcast_organisation, sample_user): 'restricted': False, 'email_from': email_from, 'created_by': sample_user, - 'crown': True, 'count_as_live': False, } service = Service.query.filter_by(name=service_name).first() @@ -274,8 +272,7 @@ def sample_broadcast_service_2(broadcast_organisation, sample_user): 'restricted': False, 'email_from': email_from, 'created_by': sample_user, - 'crown': True, - 'count_as_live': False, + 'count_as_live': False } service = Service.query.filter_by(name=service_name).first() if not service: diff --git a/tests/app/dao/test_fact_billing_dao.py b/tests/app/dao/test_fact_billing_dao.py index bf9ead199..eb803e0d7 100644 --- a/tests/app/dao/test_fact_billing_dao.py +++ b/tests/app/dao/test_fact_billing_dao.py @@ -376,7 +376,6 @@ def test_get_rate(notify_db_session): date=date(2017, 6, 1)) letter_rate = get_rate(non_letter_rates=non_letter_rates, letter_rates=letter_rates, notification_type='letter', - crown=True, letter_page_count=1, date=date(2017, 6, 1)) @@ -397,7 +396,7 @@ def test_get_rate_filters_letters_by_post_class(notify_db_session, letter_post_c 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) + rate = get_rate(non_letter_rates, letter_rates, "letter", datetime(2018, 10, 1), 2, letter_post_class) assert rate == Decimal(expected_rate) @@ -407,7 +406,7 @@ def test_get_rate_chooses_right_rate_depending_on_date(notify_db_session, date, create_letter_rate(start_date=datetime(2018, 9, 30, 23, 0), sheet_count=2, rate=0.35, post_class='second') non_letter_rates, letter_rates = get_rates_for_billing() - rate = get_rate(non_letter_rates, letter_rates, "letter", date, True, 2, "second") + rate = get_rate(non_letter_rates, letter_rates, "letter", date, 2, "second") assert rate == Decimal(expected_rate) @@ -415,7 +414,6 @@ def test_get_rate_for_letters_when_page_count_is_zero(notify_db_session): non_letter_rates, letter_rates = get_rates_for_billing() letter_rate = get_rate(non_letter_rates=non_letter_rates, letter_rates=letter_rates, notification_type='letter', - crown=True, letter_page_count=0, date=datetime.utcnow()) assert letter_rate == 0 diff --git a/tests/app/dao/test_organisation_dao.py b/tests/app/dao/test_organisation_dao.py index 3b7dc8ca4..5792beb5a 100644 --- a/tests/app/dao/test_organisation_dao.py +++ b/tests/app/dao/test_organisation_dao.py @@ -64,7 +64,6 @@ def test_update_organisation(notify_db_session): data = { 'name': 'new name', - "crown": True, "organisation_type": 'state', "agreement_signed": True, "agreement_signed_at": datetime.datetime.utcnow(), @@ -211,26 +210,11 @@ def test_update_organisation_does_not_override_service_branding( assert sample_service.letter_branding == custom_letter_branding -def test_update_organisation_updates_services_with_new_crown_type( - sample_service, - sample_organisation -): - sample_organisation.services.append(sample_service) - db.session.commit() - - assert Service.query.get(sample_service.id).crown - - dao_update_organisation(sample_organisation.id, crown=False) - - assert not Service.query.get(sample_service.id).crown - - def test_add_service_to_organisation(sample_service, sample_organisation): assert sample_organisation.services == [] sample_service.organisation_type = "federal" sample_organisation.organisation_type = "state" - sample_organisation.crown = False dao_add_service_to_organisation(sample_service, sample_organisation.id) @@ -238,7 +222,6 @@ def test_add_service_to_organisation(sample_service, sample_organisation): assert sample_organisation.services[0].id == sample_service.id assert sample_service.organisation_type == sample_organisation.organisation_type - assert sample_service.crown == sample_organisation.crown assert Service.get_history_model().query.filter_by( id=sample_service.id, version=2 diff --git a/tests/app/dao/test_services_dao.py b/tests/app/dao/test_services_dao.py index 7137194ed..50f546c78 100644 --- a/tests/app/dao/test_services_dao.py +++ b/tests/app/dao/test_services_dao.py @@ -111,7 +111,6 @@ def test_create_service(notify_db_session): assert service.active is True assert user in service_db.users assert service_db.organisation_type == 'federal' - assert service_db.crown is None assert not service.letter_branding assert not service.organisation_id @@ -139,7 +138,6 @@ def test_create_service_with_organisation(notify_db_session): assert service.active is True assert user in service_db.users assert service_db.organisation_type == 'state' - assert service_db.crown is None assert not service.letter_branding assert service.organisation_id == organisation.id assert service.organisation == organisation diff --git a/tests/app/db.py b/tests/app/db.py index 1a95df800..de99b4336 100644 --- a/tests/app/db.py +++ b/tests/app/db.py @@ -126,7 +126,6 @@ def create_service( check_if_service_exists=False, go_live_user=None, go_live_at=None, - crown=True, organisation=None, purchase_order_number=None, billing_contact_names=None, @@ -147,7 +146,6 @@ def create_service( organisation=organisation, go_live_user=go_live_user, go_live_at=go_live_at, - crown=crown, purchase_order_number=purchase_order_number, billing_contact_names=billing_contact_names, billing_contact_email_addresses=billing_contact_email_addresses, @@ -531,14 +529,13 @@ def create_rate(start_date, value, notification_type): return rate -def create_letter_rate(start_date=None, end_date=None, crown=True, sheet_count=1, rate=0.33, post_class='second'): +def create_letter_rate(start_date=None, end_date=None, sheet_count=1, rate=0.33, post_class='second'): if start_date is None: start_date = datetime(2016, 1, 1) rate = LetterRate( id=uuid.uuid4(), start_date=start_date, end_date=end_date, - crown=crown, sheet_count=sheet_count, rate=rate, post_class=post_class diff --git a/tests/app/organisation/test_rest.py b/tests/app/organisation/test_rest.py index cc5d68a23..658079596 100644 --- a/tests/app/organisation/test_rest.py +++ b/tests/app/organisation/test_rest.py @@ -68,7 +68,6 @@ def test_get_organisation_by_id(admin_request, notify_db_session): 'id', 'name', 'active', - 'crown', 'organisation_type', 'agreement_signed', 'agreement_signed_at', @@ -90,7 +89,6 @@ def test_get_organisation_by_id(admin_request, notify_db_session): assert response['id'] == str(org.id) assert response['name'] == 'test_org_1' assert response['active'] is True - assert response['crown'] is None assert response['organisation_type'] is None assert response['agreement_signed'] is None assert response['agreement_signed_by_id'] is None @@ -163,12 +161,10 @@ def test_get_organisation_by_domain( assert response['result'] == 'error' -@pytest.mark.parametrize('crown', [True, False]) -def test_post_create_organisation(admin_request, notify_db_session, crown): +def test_post_create_organisation(admin_request, notify_db_session): data = { 'name': 'test organisation', 'active': True, - 'crown': crown, 'organisation_type': 'state', } @@ -182,7 +178,6 @@ def test_post_create_organisation(admin_request, notify_db_session, crown): assert data['name'] == response['name'] assert data['active'] == response['active'] - assert data['crown'] == response['crown'] assert data['organisation_type'] == response['organisation_type'] assert len(organisations) == 1 @@ -198,7 +193,6 @@ def test_post_create_organisation_sets_default_nhs_branding_for_nhs_orgs( data = { 'name': 'test organisation', 'active': True, - 'crown': False, 'organisation_type': org_type, } @@ -218,7 +212,6 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample data = { 'name': sample_organisation.name, 'active': True, - 'crown': True, 'organisation_type': 'federal', } @@ -237,29 +230,15 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample @pytest.mark.parametrize('data, expected_error', ( ({ 'active': False, - 'crown': True, 'organisation_type': 'federal', }, 'name is a required property'), ({ 'active': False, 'name': 'Service name', - 'organisation_type': 'federal', - }, 'crown is a required property'), - ({ - 'active': False, - 'name': 'Service name', - 'crown': True, }, 'organisation_type is a required property'), ({ 'active': False, 'name': 'Service name', - 'crown': None, - 'organisation_type': 'federal', - }, 'crown None is not of type boolean'), - ({ - 'active': False, - 'name': 'Service name', - 'crown': False, 'organisation_type': 'foo', }, ( 'organisation_type foo is not one of ' @@ -283,22 +262,16 @@ def test_post_create_organisation_with_missing_data_gives_validation_error( assert response['errors'][0]['message'] == expected_error -@pytest.mark.parametrize('crown', ( - None, True, False -)) def test_post_update_organisation_updates_fields( admin_request, notify_db_session, - crown, ): org = create_organisation() data = { 'name': 'new organisation name', 'active': False, - 'crown': crown, 'organisation_type': 'federal', } - assert org.crown is None admin_request.post( 'organisation.update_organisation', @@ -313,7 +286,6 @@ def test_post_update_organisation_updates_fields( assert organisation[0].id == org.id assert organisation[0].name == data['name'] assert organisation[0].active == data['active'] - assert organisation[0].crown == crown assert organisation[0].domains == [] assert organisation[0].organisation_type == 'federal' @@ -358,7 +330,7 @@ def test_update_other_organisation_attributes_doesnt_clear_domains( admin_request.post( 'organisation.update_organisation', _data={ - 'crown': True, + 'name': 'test_org_22', }, organisation_id=org.id, _expected_status=204