def test_no_email(): """If user has no email we must throw an exception""" with patch('h.notification.reply_template.get_user_by_name') as mock_user_db: mock_user_db.return_value = {} request = _fake_request() annotation = _fake_anno(0) with pytest.raises(TemplateRenderException): rt.get_recipients(request, annotation)
def test_no_email(): """If user has no email we must throw an exception""" with patch('h.notification.reply_template.Annotation') as mock_annotation: mock_annotation.fetch = MagicMock(side_effect=fake_fetch) with patch('h.notification.reply_template.get_user_by_name') as mock_user_db: mock_user_db.return_value = {} request = _create_request() annotation = store_fake_data[1] parent = rt.parent_values(annotation) exc = False try: rt.get_recipients(request, parent) except: exc = True assert exc
def test_get_email(): """Tests whether it gives back the user.email property""" with patch('h.notification.reply_template.get_user_by_name') as mock_user_db: user = Mock() user.email = '*****@*****.**' mock_user_db.return_value = user request = _fake_request() annotation = _fake_anno(0) email = rt.get_recipients(request, annotation) assert email[0] == user.email
def test_no_email(): """If user has no email we must throw an exception""" with patch('h.notification.reply_template.Annotation') as mock_annotation: mock_annotation.fetch = MagicMock(side_effect=fake_fetch) with patch('h.notification.reply_template.get_user_by_name') as mock_user_db: mock_user_db.return_value = {} request = DummyRequest() request.domain = 'www.howtoreachtheark.now' annotation = store_fake_data[1] data = { 'parent': rt.parent_values(annotation), 'subscription': {'id': 1} } exc = False try: rt.get_recipients(request, data) except: exc = True assert exc
def test_get_email(): """Tests whether it gives back the user.email property""" with patch('h.notification.reply_template.Annotation') as mock_annotation: mock_annotation.fetch = MagicMock(side_effect=fake_fetch) with patch('h.notification.reply_template.get_user_by_name') as mock_user_db: user = Mock() user.email = '*****@*****.**' mock_user_db.return_value = user request = _create_request() annotation = store_fake_data[1] parent = rt.parent_values(annotation) email = rt.get_recipients(request, parent) assert email[0] == user.email
def test_get_email(): """Tests whether it gives back the user.email property""" with patch('h.notification.reply_template.Annotation') as mock_annotation: mock_annotation.fetch = MagicMock(side_effect=fake_fetch) with patch('h.notification.reply_template.get_user_by_name') as mock_user_db: user = Mock() user.email = '*****@*****.**' mock_user_db.return_value = user request = DummyRequest() request.domain = 'www.howtoreachtheark.now' annotation = store_fake_data[1] data = { 'parent': rt.parent_values(annotation), 'subscription': {'id': 1} } email = rt.get_recipients(request, data) assert email[0] == user.email