Пример #1
0
class TestConfigurationReaders(unittest.TestCase):
    configuration = config.Configuration()

    def setUp(self):
        os.environ['SEARCHCVE_MONGODB'] = 'testdb'
        os.environ['SEARCHCVE_MONGOHOST'] = 'localhost'
        os.environ['SEARCHCVE_MONGOPORT'] = '27017'
        os.environ['SEARCHCVE_CVESTARTYEAR'] = '2022'

    def test_MongoDB(self):
        dbname = 'testdb'
        self.assertEqual(self.configuration.getMongoDB(), dbname)

    def test_MongoHost(self):
        self.assertEqual(self.configuration.getMongoHost(), 'localhost')

    def test_MongoPort(self):
        self.assertEqual(self.configuration.getMongoPort(), '27017')

    def test_CVEStartYear(self):
        startyear = '2002'
        self.assertEqual(str((self.configuration.getCVEStartYear())),
                         startyear)
Пример #2
0
                loader=FileSystemLoader(template_directory),
                autoescape=select_autoescape(['html', 'xml']))
            self.template = template_environment.get_template(template_file)

    def render_template(self, *args, **kwargs):
        """
            Render the loaded template and write it to <output_file>.
        """
        data_dict = kwargs.get('data_dict', {})

        rendered_template = self.template.render(**kwargs)

        return rendered_template


confs = conf.Configuration()
sender = confs.getMailSender()
host = confs.getMailHost()
port = confs.getMailPort()
username = confs.getMailUsername()
password = confs.getMailPassword()
tls = confs.getMailTls()

mailer = Mailer(
    dict(transport=dict(use='smtp',
                        host=host,
                        port=port,
                        tls=tls,
                        username=username,
                        password=password)))