mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04:00
Fix the fixtures for templates lacking certain permissions
These fixtures were both calling other fixtures as functions and being called as functions in the tests. Rewriting the tests to make them Pytest 4 compatible means we are no longer using `sample_template_without_letter_permission`, so this has been deleted.
This commit is contained in:
@@ -23,11 +23,7 @@ from app.models import (
|
||||
from app.dao.templates_dao import dao_get_template_by_id, dao_redact_template
|
||||
|
||||
from tests import create_authorization_header
|
||||
from tests.app.conftest import (
|
||||
sample_template as create_sample_template,
|
||||
sample_template_without_email_permission,
|
||||
sample_template_without_letter_permission,
|
||||
sample_template_without_sms_permission)
|
||||
from tests.app.conftest import sample_template as create_sample_template
|
||||
from tests.app.db import (
|
||||
create_service, create_letter_contact, create_template, create_notification,
|
||||
create_template_folder,
|
||||
@@ -246,14 +242,21 @@ def test_should_raise_error_on_create_if_no_permission(
|
||||
assert json_resp['message'] == expected_error
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template_factory, expected_error', [
|
||||
(sample_template_without_sms_permission, {'template_type': ['Updating text message templates is not allowed']}),
|
||||
(sample_template_without_email_permission, {'template_type': ['Updating email templates is not allowed']}),
|
||||
(sample_template_without_letter_permission, {'template_type': ['Updating letter templates is not allowed']})
|
||||
@pytest.mark.parametrize('template_type, permissions, expected_error', [
|
||||
(SMS_TYPE, [EMAIL_TYPE], {'template_type': ['Updating text message templates is not allowed']}),
|
||||
(EMAIL_TYPE, [LETTER_TYPE], {'template_type': ['Updating email templates is not allowed']}),
|
||||
(LETTER_TYPE, [SMS_TYPE], {'template_type': ['Updating letter templates is not allowed']})
|
||||
])
|
||||
def test_should_be_error_on_update_if_no_permission(
|
||||
client, sample_user, template_factory, expected_error, notify_db, notify_db_session):
|
||||
template_without_permission = template_factory(notify_db, notify_db_session)
|
||||
client,
|
||||
sample_user,
|
||||
notify_db_session,
|
||||
template_type,
|
||||
permissions,
|
||||
expected_error,
|
||||
):
|
||||
service = create_service(service_permissions=permissions)
|
||||
template_without_permission = create_template(service, template_type=template_type)
|
||||
data = {
|
||||
'content': 'new template content',
|
||||
'created_by': str(sample_user.id)
|
||||
|
||||
Reference in New Issue
Block a user