Skip to content

Commit

Permalink
fix access to templates during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
konstan committed Dec 5, 2023
1 parent adf50c9 commit fffb4b6
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions tests/test_notify_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import unittest

import notify_email
from notify_email import get_recipients, html_content, email_template, EMAIL_TEMPLATE_FILE
from notify_email import get_recipients, html_content, email_template

notify_email.EMAIL_TEMPLATE = email_template(
os.path.join('..', 'src', EMAIL_TEMPLATE_FILE))
notify_email.EMAIL_TEMPLATES['default'] = email_template(
os.path.join('src', notify_email.EMAIL_TEMPLATE_DEFAULT_FILE))

notify_email.EMAIL_TEMPLATES['app-pub'] = email_template(
os.path.join('src', notify_email.EMAIL_TEMPLATE_APP_PUB_FILE))


class NotifyEmail(unittest.TestCase):
Expand All @@ -30,3 +33,50 @@ def test_html_content(self):
html = html_content(msg)
assert 'Condition' in html
assert 'Value' in html

def test_AppAppBqPublishedDeploymentGroupUpdateNotification(self):

affected_dpl_grp = 'affected deployment group name'
msg = {
'TEMPLATE': 'app-pub',

'SUBS_ID': 'subscription-config/891bdb6c-fb8c-41e6-9023-e317757365ab',
'SUBS_NAME': 'Apps Published for Deployment',
'SUBS_DESCRIPTION': 'Apps Published for Deployment',

'TRIGGER_RESOURCE_PATH': 'apps/test/new-application',
'TRIGGER_RESOURCE_NAME': 'test',

'RESOURCE_URI': 'deployment-groups/8c9cf316-6092-4d98-97e6-bbf030c1a1ce?deployment-groups-detail-tab=apps',
'RESOURCE_NAME': f'Update Deployment Group: {affected_dpl_grp}',

'TIMESTAMP': '2023-11-29T13:22:26Z',
'RECOVERY': True
}
html = html_content(msg)
open('email-Apps-Published-for-Deployment.html', 'w').write(html)

def test_AppPublishedAppsBouquetUpdateNotification(self):

affected_app_name = 'affected app name'
trigger_app_name = 'trigger app name'
msg = {
'TEMPLATE': 'app-pub',

'SUBS_ID': 'subscription-config/891bdb6c-fb8c-41e6-9023-e317757365ab',
'DESTINATION': 'https://hooks.slack.com/services/foo',

'SUBS_NAME': 'Apps Published for App Bouquet',
'SUBS_DESCRIPTION': 'Apps Published for App Bouquet',

'TRIGGER_RESOURCE_PATH': 'apps/test/trigger-app-name',
'TRIGGER_RESOURCE_NAME': trigger_app_name,

'RESOURCE_URI': 'my-app-bqs/new-app-bq',
'RESOURCE_NAME': f'Update App Bouquet: {affected_app_name}',

'TIMESTAMP': '2023-11-29T13:22:26Z',
'RECOVERY': True
}
html = html_content(msg)
open('email-Apps-Published-for-AppBq.html', 'w').write(html)

0 comments on commit fffb4b6

Please sign in to comment.