From 68c50ff824dfe5f3f983efa5eceff862c71f32cb Mon Sep 17 00:00:00 2001 From: Cliff Hill Date: Wed, 22 Nov 2023 11:55:51 -0500 Subject: [PATCH] Tests being configured. Signed-off-by: Cliff Hill --- app/models.py | 6 ++-- tests/app/dao/test_invited_user_dao.py | 2 +- tests/app/test_model.py | 43 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/app/models.py b/app/models.py index 1a7247625..a90ab65dc 100644 --- a/app/models.py +++ b/app/models.py @@ -448,11 +448,13 @@ class Organization(db.Model): @property def agreement_active(self): - return self.agreement and self.agreement.status == AgreementStatus.active + return ( + self.agreement.status == AgreementStatus.active if self.agreement else False + ) @property def has_mou(self): - return self.agreement and self.agreement.type == AgreementType.MOU + return self.agreement.type == AgreementType.MOU if self.agreement else False def serialize(self): return { diff --git a/tests/app/dao/test_invited_user_dao.py b/tests/app/dao/test_invited_user_dao.py index c1994cf56..b0a7d75de 100644 --- a/tests/app/dao/test_invited_user_dao.py +++ b/tests/app/dao/test_invited_user_dao.py @@ -138,7 +138,7 @@ def test_should_not_delete_invitations_less_than_two_days_old( make_invitation( sample_user, sample_service, - age=two_days - one_second, # Not quite two days + age=two_days - one_second, # Not quite two days email_address="valid@2.com", ) make_invitation( diff --git a/tests/app/test_model.py b/tests/app/test_model.py index e2a2d1221..c314c656c 100644 --- a/tests/app/test_model.py +++ b/tests/app/test_model.py @@ -15,6 +15,8 @@ from app.models import ( NOTIFICATION_TECHNICAL_FAILURE, SMS_TYPE, Agreement, + AgreementStatus, + AgreementType, AnnualBilling, Notification, NotificationHistory, @@ -28,6 +30,7 @@ from app.models import ( from tests.app.db import ( create_inbound_number, create_notification, + create_organization, create_rate, create_reply_to_email, create_service, @@ -412,6 +415,46 @@ def test_rate_str(): assert rate.__str__() == "1.5 sms 2023-01-01 00:00:00" +@pytest.mark.parametrize( + ["agreement_type", "expected"], + ( + (AgreementType.IAA, False), + (AgreementType.MOU, True), + ), +) +def test_organization_agreement_mou(notify_db_session, agreement_type, expected): + now = datetime.utcnow() + agree = Agreement() + agree.id = "whatever" + agree.start_time = now + agree.end_time = now + agree.status = AgreementStatus.ACTIVE + agree.type = agreement_type + organization = create_organization(name="Something") + organization.agreements.append(agree) + assert organization.has_mou == expected + + +@pytest.mark.parametrize( + ["agreement_status", "expected"], + ( + (AgreementStatus.EXPIRED, False), + (AgreementStatus.ACTIVE, True), + ), +) +def test_organization_agreement_active(notify_db_session, agreement_status, expected): + now = datetime.utcnow() + agree = Agreement() + agree.id = "whatever" + agree.start_time = now + agree.end_time = now + agree.status = agreement_status + agree.type = AgreementType.IAA + organization = create_organization(name="Something") + organization.agreements.append(agree) + assert organization.active == expected + + def test_agreement_serialize(): agree = Agreement() agree.id = "abc"