コード例 #1
0
ファイル: test_app.py プロジェクト: jpopelka/anitya
    def test_db_config(self):
        """Assert creating the application configures the scoped session."""
        # Assert the scoped session is not bound.
        self.assertRaises(UnboundExecutionError, Session.get_bind)
        Session.remove()

        app.create({'DB_URL': 'sqlite://'})
        self.assertEqual('sqlite://', str(Session().get_bind().url))
コード例 #2
0
ファイル: test_app.py プロジェクト: fedora-infra/anitya
    def test_db_config(self):
        """Assert creating the application configures the scoped session."""
        # Assert the scoped session is not bound.
        self.assertRaises(UnboundExecutionError, Session.get_bind)
        Session.remove()

        app.create(
            {"DB_URL": "sqlite://", "SOCIAL_AUTH_USER_MODEL": "anitya.db.models.User"}
        )
        self.assertEqual("sqlite://", str(Session().get_bind().url))
コード例 #3
0
ファイル: test_app.py プロジェクト: odra/anitya
    def test_db_config(self):
        """Assert creating the application configures the scoped session."""
        # Assert the scoped session is not bound.
        self.assertRaises(UnboundExecutionError, Session.get_bind)
        Session.remove()

        app.create({
            'DB_URL': 'sqlite://',
            'SOCIAL_AUTH_USER_MODEL': 'anitya.db.models.User',
        })
        self.assertEqual('sqlite://', str(Session().get_bind().url))
コード例 #4
0
ファイル: test_app.py プロジェクト: fedora-infra/anitya
    def test_email_config(self):
        """Assert a SMTPHandler is added to the anitya logger when ``EMAIL_ERRORS=True``."""
        config = {
            "DB_URL": "sqlite://",
            "SOCIAL_AUTH_USER_MODEL": "anitya.db.models.User",
            "EMAIL_ERRORS": True,
            "SMTP_SERVER": "smtp.example.com",
            "ADMIN_EMAIL": "*****@*****.**",
        }
        anitya_logger = logging.getLogger("anitya")
        anitya_logger.handlers = []

        app.create(config)

        self.assertEqual(1, len(anitya_logger.handlers))
        self.assertEqual("smtp.example.com", anitya_logger.handlers[0].mailhost)
        self.assertEqual(["*****@*****.**"], anitya_logger.handlers[0].toaddrs)
コード例 #5
0
ファイル: test_app.py プロジェクト: jpopelka/anitya
    def test_email_config(self):
        """Assert a SMTPHandler is added to the anitya logger when ``EMAIL_ERRORS=True``."""
        config = {
            'DB_URL': 'sqlite://',
            'EMAIL_ERRORS': True,
            'SMTP_SERVER': 'smtp.example.com',
            'ADMIN_EMAIL': '*****@*****.**',
        }
        anitya_logger = logging.getLogger('anitya')
        anitya_logger.handlers = []

        app.create(config)

        self.assertEqual(1, len(anitya_logger.handlers))
        self.assertEqual('smtp.example.com',
                         anitya_logger.handlers[0].mailhost)
        self.assertEqual(['*****@*****.**'],
                         anitya_logger.handlers[0].toaddrs)
コード例 #6
0
    def test_email_config(self):
        """Assert a SMTPHandler is added to the anitya logger when ``EMAIL_ERRORS=True``."""
        config = {
            "DB_URL": "sqlite://",
            "SOCIAL_AUTH_USER_MODEL": "anitya.db.models.User",
            "EMAIL_ERRORS": True,
            "SMTP_SERVER": "smtp.example.com",
            "ADMIN_EMAIL": "*****@*****.**",
        }
        anitya_logger = logging.getLogger("anitya")
        anitya_logger.handlers = []

        app.create(config)

        self.assertEqual(1, len(anitya_logger.handlers))
        self.assertEqual("smtp.example.com",
                         anitya_logger.handlers[0].mailhost)
        self.assertEqual(["*****@*****.**"],
                         anitya_logger.handlers[0].toaddrs)
コード例 #7
0
ファイル: base.py プロジェクト: livingeek/anitya
    def setUp(self):
        """Set a basic test environment.

        This simply starts recording a VCR on start-up and stops on tearDown.
        """
        self.config = config.config.copy()
        self.config['TESTING'] = True
        self.flask_app = app.create(self.config)

        cwd = os.path.dirname(os.path.realpath(__file__))
        my_vcr = vcr.VCR(cassette_library_dir=os.path.join(
            cwd, 'request-data/'),
                         record_mode='once')
        self.vcr = my_vcr.use_cassette(self.id())
        self.vcr.__enter__()
        self.addCleanup(self.vcr.__exit__, None, None, None)
コード例 #8
0
ファイル: base.py プロジェクト: fedora-infra/anitya
    def setUp(self):
        """Set a basic test environment.

        This simply starts recording a VCR on start-up and stops on tearDown.
        """
        self.config = config.config.copy()
        self.config["TESTING"] = True
        self.flask_app = app.create(self.config)

        cwd = os.path.dirname(os.path.realpath(__file__))
        my_vcr = vcr.VCR(
            cassette_library_dir=os.path.join(cwd, "request-data/"), record_mode="once"
        )
        self.vcr = my_vcr.use_cassette(self.id())
        self.vcr.__enter__()
        self.addCleanup(self.vcr.__exit__, None, None, None)
コード例 #9
0
    def setUp(self):
        """Set a basic test environment.

        This simply starts recording a VCR on start-up and stops on tearDown.
        """
        self.config = config.config.copy()
        self.config["TESTING"] = True
        self.flask_app = app.create(self.config)

        cwd = os.path.dirname(os.path.realpath(__file__))
        my_vcr = vcr.VCR(
            cassette_library_dir=os.path.join(cwd, "request-data/"),
            record_mode="once",
            decode_compressed_response=True,
        )
        self.vcr = my_vcr.use_cassette(
            self.id(), filter_headers=[("Authorization", "bearer foobar")]
        )
        self.vcr.__enter__()
        self.addCleanup(self.vcr.__exit__, None, None, None)
コード例 #10
0
    def setUp(self):
        """Set a basic test environment.

        This simply starts recording a VCR on start-up and stops on tearDown.
        """
        mock_oidc = mock.patch(
            'anitya.authentication.oidc',
            OpenIDConnect(credentials_store=flask.session),
        )
        mock_oidc.start()
        self.addCleanup(mock_oidc.stop)
        mock_oid = mock.patch('anitya.authentication.oid', OpenID())
        mock_oid.start()
        self.addCleanup(mock_oid.stop)

        self.flask_app = app.create(config.config)

        cwd = os.path.dirname(os.path.realpath(__file__))
        my_vcr = vcr.VCR(
            cassette_library_dir=os.path.join(cwd, 'request-data/'), record_mode='once')
        self.vcr = my_vcr.use_cassette(self.id())
        self.vcr.__enter__()
        self.addCleanup(self.vcr.__exit__, None, None, None)
コード例 #11
0
ファイル: test_app.py プロジェクト: fedora-infra/anitya
 def test_default_config(self):
     """Assert when no configuration is provided, :data:`anitya.config.config` is used."""
     application = app.create()
     for key in anitya_config:
         self.assertEqual(anitya_config[key], application.config[key])
コード例 #12
0
ファイル: runserver.py プロジェクト: fedora-infra/anitya
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
An instance of the Flask application.

This is intended to be run with the Flask CLI for development purposes only::

    $ export ANITYA_WEB_CONFIG=<config_file>
    $ export FLASK_DEBUG=1
    $ export FLASK_APP=<this_file>
    $ flask run --host 0.0.0.0 --port 5000
"""

from anitya.app import create


app = create()
コード例 #13
0
#!/usr/bin/python

from anitya import app as application

app = application.create()
コード例 #14
0
ファイル: test_app.py プロジェクト: odra/anitya
 def test_default_config(self):
     """Assert when no configuration is provided, :data:`anitya.config.config` is used."""
     application = app.create()
     for key in anitya_config:
         self.assertEqual(anitya_config[key], application.config[key])
コード例 #15
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
An instance of the Flask application.

This is intended to be run with the Flask CLI for development purposes only::

    $ export ANITYA_WEB_CONFIG=<config_file>
    $ export FLASK_DEBUG=1
    $ export FLASK_APP=<this_file>
    $ flask run --host 0.0.0.0 --port 5000
"""

from anitya.app import create

app = create()