Added a base MessageType for ace
added unit tests updated edx-ace version fixed quality violations Fixed quality violations Changed ACEMessageType to BaseMessageType
This commit is contained in:
13
openedx/core/djangoapps/ace_common/message.py
Normal file
13
openedx/core/djangoapps/ace_common/message.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""
|
||||
Base Message types to be used to construct ace messages.
|
||||
"""
|
||||
from edx_ace.message import MessageType
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
|
||||
|
||||
class BaseMessageType(MessageType):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BaseMessageType, self).__init__(*args, **kwargs)
|
||||
from_address = configuration_helpers.get_value('email_from_address')
|
||||
if from_address:
|
||||
self.options.update({'from_address': from_address}) # pylint: disable=no-member
|
||||
29
openedx/core/djangoapps/ace_common/tests/test_message.py
Normal file
29
openedx/core/djangoapps/ace_common/tests/test_message.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
Tests for ace message module
|
||||
"""
|
||||
import ddt
|
||||
from mock import patch
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from openedx.core.djangoapps.ace_common.message import BaseMessageType
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestAbsoluteUrl(TestCase):
|
||||
|
||||
@ddt.data(
|
||||
('test@example.com', True),
|
||||
('', False),
|
||||
(None, False),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_from_email_address_in_message(self, from_address, has_from_address):
|
||||
"""
|
||||
Tests presence of from_address option in ace message
|
||||
"""
|
||||
with patch("openedx.core.djangoapps.site_configuration.helpers.get_value", return_value=from_address):
|
||||
ace_message_type = BaseMessageType()
|
||||
self.assertEqual('from_address' in ace_message_type.options, has_from_address)
|
||||
if from_address:
|
||||
self.assertEqual(ace_message_type.options.get('from_address'), from_address)
|
||||
Reference in New Issue
Block a user