mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-06 03:02:50 -05:00
Remove sample_notification_with_api_key fixture
This was only used once and was not Pytest 4 compatible.
This commit is contained in:
@@ -628,18 +628,6 @@ def sample_letter_notification(sample_letter_template):
|
||||
return create_notification(sample_letter_template, reference='foo', personalisation=address)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def sample_notification_with_api_key(notify_db, notify_db_session):
|
||||
notification = sample_notification(notify_db, notify_db_session)
|
||||
notification.api_key = sample_api_key(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
name='Test key'
|
||||
)
|
||||
notification.api_key_id = notification.api_key.id
|
||||
return notification
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def sample_email_notification(notify_db, notify_db_session):
|
||||
created_at = datetime.utcnow()
|
||||
|
||||
@@ -511,11 +511,14 @@ def create_letter_rate(start_date=None, end_date=None, crown=True, sheet_count=1
|
||||
return rate
|
||||
|
||||
|
||||
def create_api_key(service, key_type=KEY_TYPE_NORMAL):
|
||||
def create_api_key(service, key_type=KEY_TYPE_NORMAL, key_name=None):
|
||||
id_ = uuid.uuid4()
|
||||
|
||||
name = key_name if key_name else '{} api key {}'.format(key_type, id_)
|
||||
|
||||
api_key = ApiKey(
|
||||
service=service,
|
||||
name='{} api key {}'.format(key_type, id_),
|
||||
name=name,
|
||||
created_by=service.created_by,
|
||||
key_type=key_type,
|
||||
id=id_,
|
||||
|
||||
@@ -4,6 +4,7 @@ from sqlalchemy import desc
|
||||
|
||||
from app.dao.provider_details_dao import dao_update_provider_details
|
||||
from app.models import ProviderDetailsHistory
|
||||
from tests.app.db import create_api_key
|
||||
|
||||
|
||||
def test_job_schema_doesnt_return_notifications(sample_notification_with_job):
|
||||
@@ -25,10 +26,13 @@ def test_notification_schema_ignores_absent_api_key(sample_notification_with_job
|
||||
assert data['key_name'] is None
|
||||
|
||||
|
||||
def test_notification_schema_adds_api_key_name(sample_notification_with_api_key):
|
||||
def test_notification_schema_adds_api_key_name(sample_notification):
|
||||
from app.schemas import notification_with_template_schema
|
||||
|
||||
data = notification_with_template_schema.dump(sample_notification_with_api_key).data
|
||||
api_key = create_api_key(sample_notification.service, key_name='Test key')
|
||||
sample_notification.api_key = api_key
|
||||
|
||||
data = notification_with_template_schema.dump(sample_notification).data
|
||||
assert data['key_name'] == 'Test key'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user