test that email is sent when user is created
This commit is contained in:
parent
749ca41080
commit
3cba9680f5
|
@ -69,7 +69,7 @@ class MailService:
|
||||||
if '@' in auth_user:
|
if '@' in auth_user:
|
||||||
auth_user = auth_user[:auth_user.index('@')]
|
auth_user = auth_user[:auth_user.index('@')]
|
||||||
|
|
||||||
if user.is_club():
|
if user.terms:
|
||||||
prog = 'addclubrep'
|
prog = 'addclubrep'
|
||||||
desc = 'Club Rep'
|
desc = 'Club Rep'
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -23,7 +23,7 @@ class MockHandler:
|
||||||
async def handle_DATA(self, server, session, envelope):
|
async def handle_DATA(self, server, session, envelope):
|
||||||
msg = {
|
msg = {
|
||||||
'from': envelope.mail_from,
|
'from': envelope.mail_from,
|
||||||
'to': envelope.rcpt_tos[0],
|
'to': ','.join(envelope.rcpt_tos),
|
||||||
'content': envelope.content.decode(),
|
'content': envelope.content.decode(),
|
||||||
}
|
}
|
||||||
self.mock_server.messages.append(msg)
|
self.mock_server.messages.append(msg)
|
||||||
|
|
|
@ -12,7 +12,8 @@ def test_api_user_not_found(client):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module')
|
@pytest.fixture(scope='module')
|
||||||
def create_user_resp(client, mocks_for_create_user):
|
def create_user_resp(client, mocks_for_create_user, mock_mail_server):
|
||||||
|
mock_mail_server.messages.clear()
|
||||||
status, data = client.post('/api/members', json={
|
status, data = client.post('/api/members', json={
|
||||||
'uid': 'test_1',
|
'uid': 'test_1',
|
||||||
'cn': 'Test One',
|
'cn': 'Test One',
|
||||||
|
@ -35,7 +36,7 @@ def create_user_result(create_user_resp):
|
||||||
return data[-1]['result']
|
return data[-1]['result']
|
||||||
|
|
||||||
|
|
||||||
def test_api_create_user(cfg, create_user_resp):
|
def test_api_create_user(cfg, create_user_resp, mock_mail_server):
|
||||||
_, data = create_user_resp
|
_, data = create_user_resp
|
||||||
min_uid = cfg.get('members_min_id')
|
min_uid = cfg.get('members_min_id')
|
||||||
expected = [
|
expected = [
|
||||||
|
@ -62,6 +63,12 @@ def test_api_create_user(cfg, create_user_resp):
|
||||||
}},
|
}},
|
||||||
]
|
]
|
||||||
assert data == expected
|
assert data == expected
|
||||||
|
# Two messages should have been sent: a welcome message to the new member,
|
||||||
|
# and an announcement to the ceo mailing list
|
||||||
|
assert len(mock_mail_server.messages) == 2
|
||||||
|
assert mock_mail_server.messages[0]['to'] == 'test_1@csclub.internal'
|
||||||
|
assert mock_mail_server.messages[1]['to'] == 'ceo@csclub.internal,ctdalek@csclub.internal'
|
||||||
|
mock_mail_server.messages.clear()
|
||||||
|
|
||||||
|
|
||||||
def test_api_next_uid(cfg, client, create_user_result):
|
def test_api_next_uid(cfg, client, create_user_result):
|
||||||
|
|
|
@ -208,7 +208,6 @@ def mock_mailman_server():
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def mailman_srv(mock_mailman_server, cfg, http_client):
|
def mailman_srv(mock_mailman_server, cfg, http_client):
|
||||||
# TODO: test the RemoteMailmanService as well
|
|
||||||
mailman = MailmanService()
|
mailman = MailmanService()
|
||||||
component.getGlobalSiteManager().registerUtility(mailman, IMailmanService)
|
component.getGlobalSiteManager().registerUtility(mailman, IMailmanService)
|
||||||
return mailman
|
return mailman
|
||||||
|
|
Loading…
Reference in New Issue