def test_config_section_mailer(self):
        #arrange

        #act
        config_to = helpers.config_section("mailer")['mail_to']

        #assert
        self.assertIsNot(config_to, '')
    def test_config_section_size_value(self):
        #arrange

        #act
        config_size = helpers.config_section("trainers_spider")['size']
        sizes = config_size.split(",")

        #assert
        for size in sizes:
            self.assertTrue(4 <= int(size) <= 14)
    def test_config_section_currency(self):
        #arrange
        currencies = ['EUR', 'USD', 'GBP']
        flag = False

        #act
        config_curr = helpers.config_section("general")['currency']
        if config_curr in currencies:
            flag = True

        #assert
        self.assertTrue(flag)
Exemple #4
0
def send_mail(body):
    '''Sends email
          :param body: The body of mail.
          :type string:
    '''
    # convert to str to escape issue in twisted
    server = helpers.config_section("mailer")['smtp_host']
    mail_from = helpers.config_section("mailer")['mail_from']
    user = helpers.config_section("mailer")['smtp_user']
    password = helpers.config_section("mailer")['smtp_pass']
    port = helpers.config_section("mailer")['smtp_port']
    mailer = MailSender(server, mail_from, user, password, int(port), False,
                        False)
    recipient = helpers.config_section("mailer")['mail_to']
    try:
        resp = mailer.send(to=recipient,
                           subject='Prodirect trainers',
                           body=body,
                           mimetype='text/html')
        return resp
    except Exception:
        print(resp)