Beispiel #1
0
 def test_test_email_with_invalid_email_address(self, access_token_first):
     """
     In this test we will send a test email to an invalid email address which will cause failure while sending email
     via SES (500 Error).
     :param access_token_first: access token
     """
     subject = "Test Email %s" % fake.uuid4()
     data = TEST_MAIL_DATA.copy()
     data['subject'] = subject
     data['email_address_list'] = ['some_invalid_email_%s' % fake.uuid4()]
     CampaignsTestsHelpers.request_with_invalid_input(self.HTTP_METHOD, self.URL, access_token_first, data=data,
                                                      expected_status_code=codes.INTERNAL_SERVER_ERROR,
                                                      expected_error_code=ERROR_SENDING_EMAIL[1])
Beispiel #2
0
def create_dummy_kaiser_domain():
    """
    This creates a domain with name containing word "Kaiser"
    """
    domain = Domain(name='test_domain_{}_{}'.format('kaiser', fake.uuid4()))
    domain.save()
    return domain.id
Beispiel #3
0
 def test_send_test_mail_without_optional_parameter(self, access_token_first):
     """
     In this test, we will send a test email without optional parameter to test email account and assert we get OK
     response.
     """
     subject = "Test Email %s" % fake.uuid4()
     data = TEST_MAIL_DATA.copy()
     del data['body_text']  # This parameter is optional
     data['subject'] = subject
     response = send_request(self.HTTP_METHOD, self.URL, access_token_first, data)
     assert response.status_code == requests.codes.OK
Beispiel #4
0
 def test_with_invalid_data(self, access_token_first_for_email_templates):
     """
     Trying to create a template folder with 1) no data and 2) Non-JSON data.
     It should result in invalid usage error.
     """
     template_folder_name = 'test_template_folder_{}'.format(fake.uuid4())
     data = {'name': template_folder_name}
     for data in (data, None):
         CampaignsTestsHelpers.request_with_invalid_input(self.HTTP_METHOD, self.URL,
                                                          access_token_first_for_email_templates,
                                                          data=data, is_json=False,
                                                          expected_error_code=INVALID_REQUEST_BODY[1])
Beispiel #5
0
def create_email_campaign_in_db(user_id, add_subject=True):
    """
    This creates an email campaign for given user
    """
    email_campaign = EmailCampaign(
        name=fake.name(),
        user_id=user_id,
        is_hidden=0,
        subject='{}-{}'.format('Test campaign created in db',
                               fake.uuid4()[0:8]) if add_subject else '',
        description=fake.paragraph(),
        _from=TEST_EMAIL_ID,
        reply_to=TEST_EMAIL_ID,
        body_text=fake.sentence(),
        body_html="<html><body><a href=%s>Email campaign test</a></body></html>"
        % fake.url(),
    )
    EmailCampaign.save(email_campaign)
    return email_campaign
Beispiel #6
0
}, {
    'from':
    fake.safe_email(),
    'reply_to':
    fake.safe_email(),
    'body_text':
    fake.sentence(),
    'start_datetime':
    DatetimeUtils.to_utc_str(datetime.utcnow() + timedelta(minutes=20)),
    'end_datetime':
    DatetimeUtils.to_utc_str(datetime.utcnow() + timedelta(minutes=40))
}]

SPECIAL_CHARACTERS = '!@#$%^&*()_+'
TEST_MAIL_DATA = {
    "subject": "Test Email-%s-%s" % (fake.uuid4()[0:8], SPECIAL_CHARACTERS),
    "from": fake.name(),
    "body_html": "<html><body><h1>Welcome to email campaign service "
    "<a href=https://www.github.com>Github</a></h1></body></html>",
    "body_text": fake.sentence() + fake.uuid4() + SPECIAL_CHARACTERS,
    "email_address_list": [app.config[TalentConfigKeys.GT_GMAIL_ID]],
    "reply_to": fake.safe_email()
}


class EmailCampaignTypes(object):
    """
    This defines 2 types of email-campaigns
    """
    WITH_CLIENT = 'with_client'
    WITHOUT_CLIENT = 'without_client'