From ef12701dbb8b58a49e0e007821cefb53d7d53f7e Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Tue, 19 Nov 2019 13:58:44 -0500 Subject: [PATCH] Default creating an invite in the AppliationRoleFactory to True and fix tests --- tests/factories.py | 6 +++--- tests/routes/applications/test_settings.py | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/factories.py b/tests/factories.py index 56357efb..8b78ffc5 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -202,7 +202,7 @@ class EnvironmentFactory(Base): for member in with_members: user = member.get("user", UserFactory.create()) application_role = ApplicationRoleFactory.create( - application=environment.application, user=user, invite=True + application=environment.application, user=user ) role_name = member["role_name"] EnvironmentRoleFactory.create( @@ -235,7 +235,7 @@ class ApplicationRoleFactory(Base): @classmethod def _create(cls, model_class, *args, **kwargs): - with_invite = kwargs.pop("invite", False) + with_invite = kwargs.pop("invite", True) app_role = super()._create(model_class, *args, **kwargs) if with_invite: @@ -269,7 +269,7 @@ class ApplicationInvitationFactory(Base): email = factory.Faker("email") status = InvitationStatus.PENDING expiration_time = PortfolioInvitations.current_expiration_time() - role = factory.SubFactory(ApplicationRoleFactory) + role = factory.SubFactory(ApplicationRoleFactory, invite=False) class AttachmentFactory(Base): diff --git a/tests/routes/applications/test_settings.py b/tests/routes/applications/test_settings.py index d97132b6..4961065e 100644 --- a/tests/routes/applications/test_settings.py +++ b/tests/routes/applications/test_settings.py @@ -110,13 +110,11 @@ def test_edit_application_environments_obj(app, client, user_session): {"env"}, ) env = application.environments[0] - app_role1 = ApplicationRoleFactory.create(application=application, invite=True) + app_role1 = ApplicationRoleFactory.create(application=application) env_role1 = EnvironmentRoleFactory.create( application_role=app_role1, environment=env, role=CSPRole.BASIC_ACCESS.value ) - app_role2 = ApplicationRoleFactory.create( - application=application, user=None, invite=True - ) + app_role2 = ApplicationRoleFactory.create(application=application, user=None) env_role2 = EnvironmentRoleFactory.create( application_role=app_role2, environment=env, role=CSPRole.NETWORK_ADMIN.value )