Example #1
0
    def setUp(self):
        """Recreate our indexes inside MongoDB

        """
        # Create flask app and context
        self.app = create_app(config_dict={
            'TESTING': 'True',
            'SERVER_NAME': 'localhost',
            'WTF_CSRF_ENABLED': False,
            'MONGO_DBNAME': 'pjuu_testing',
            'REDIS_DB': 2,
            'SESSION_REDIS_DB': 3
        })
        self.app_ctx = self.app.app_context()
        self.app_ctx.push()

        r.flushdb()

        # Ensure the MongoDB indexes are present
        ensure_indexes()
Example #2
0
    def setUp(self):
        """Recreate our indexes inside MongoDB

        """
        # Create flask app and context
        self.app = create_app(
            config_dict={
                'TESTING': 'True',
                'SERVER_NAME': 'localhost',
                'WTF_CSRF_ENABLED': False,
                'MONGO_DBNAME': 'pjuu_testing',
                'REDIS_DB': 2,
                'SESSION_REDIS_DB': 3
            })
        self.app_ctx = self.app.app_context()
        self.app_ctx.push()

        r.flushdb()

        # Ensure the MongoDB indexes are present
        ensure_indexes()
Example #3
0
    def setUp(self):
        """Recreate our indexes inside MongoDB

        """
        # Create flask app and context
        self.app = create_app(
            config_dict={
                "TESTING": "True",
                "SERVER_NAME": "localhost",
                "WTF_CSRF_ENABLED": False,
                "MONGO_DBNAME": "pjuu_testing",
                "REDIS_DB": 2,
                "SESSION_REDIS_DB": 3,
            }
        )
        self.app_ctx = self.app.app_context()
        self.app_ctx.push()

        r.flushdb()

        # Ensure the MongoDB indexes are present
        ensure_indexes()
Example #4
0
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

# Stdlib imports
import code
# Pjuu imports
from pjuu import create_app


if __name__ == '__main__':
    """
    Starts the Python interpreter but before anything can be typed in
    will initialise the application and an app context
    """
    # Create app
    _app = create_app()
    # Create app_context
    _ctx = _app.app_context()
    # Push the context
    _ctx.push()

    # Print some information
    print 'Pjuu shell, app created at \'_app\', ' \
          'context created at \'_ctx\' and pushed'

    # Use Pjuu from the command line without all the overhead of having to do
    # the above
    code.interact()

    # Not sure if this will ever be called, but lets be precise
    _ctx.pop()
Example #5
0
    os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)

import pymongo  # noqa

from pjuu import create_app  # noqa
from pjuu.lib.parser import parse_post  # noqa


m = pymongo.MongoClient(host='localhost')


if __name__ == '__main__':
    # Set up Flask environment
    app = create_app()
    ctx = app.app_context()
    ctx.push()

    for post in m.pjuu.posts.find():
        # Parse the posts body like it has just come in
        if post.get('links') is None and post.get('mentions') is None and \
                post.get('hashtags') is None:

            links, mentions, hashtags = parse_post(post.get('body'))

            if links:
                post['links'] = links
            if mentions:
                post['mentions'] = mentions
            if hashtags:
Example #6
0
# -*- coding: utf8 -*-

"""Create a celery application for use with the celery worker

:license: AGPL v3, see LICENSE for more details
:copyright: 2014-2017 Joe Doherty

"""

from pjuu import create_app
from pjuu import celery


application = create_app()
application.app_context().push()

# Simply uses the import so it's not un-used
# There may be a nicer way of doing this `pragma: noqa` doesn't seem to work
celery = celery
Example #7
0
    Travis-CI.

    Note: If there are major errors this may never get round to returning
          a 1 please be careful. Tavis-CI may think the tests have passed
    Note: This may change to pytest or nosetest in the future.
    """
    # Create our testing app with explicit test settings
    # These are for our uses when deploying so that Travis-CI will run the
    # the unittest's.
    app = create_app(config_dict={
        # Testing needs to be enabled so that we can get passed the
        # in tests and also so Flask-Mail does not send mail
        'TESTING': 'True',
        # We need a SERVER_NAME so that we can use url_for()
        'SERVER_NAME': 'localhost',
        # This just stops us getting through forms if True
        'WTF_CSRF_ENABLED': False,
        # Change the Redis database numbers so that we do not overwrite
        # our data each time we run the tests
        'REDIS_DB': 2,
        'SESSION_REDIS_DB': 3
    })

    # Create a request context to run all of the tests in.
    # The FrontendTests in each module will create a test request context
    # before each test and pop it afterwards
    with app.app_context():
        # Prepare for testing
        test_loader = unittest.defaultTestLoader
        test_runner = unittest.TextTestRunner()
        test_suite = test_loader.discover('tests', pattern='test_*.py')
Example #8
0
# -*- coding: utf8 -*-
"""This file is what should be imported to deploy Pjuu.

This is just a simple system for loading an application. If you rename this
file too .wsgi rather than .py it should work with Apache also.

:license: AGPL v3, see LICENSE for more details
:copyright: 2014-2016 Joe Doherty

"""

# Pjuu imports
from pjuu import create_app

# Create the Pjuu WSGI application
# You can pass in your production settings to the create_app() so you do not
# have to override any settings in settings.py :)
# This is the worlds most simple file. Looks at __init__ for more information.
# It is easy to load Pjuu with Gunicorn with pjuu.wsgi:application
# This file also allows easy deployment with mod_wsgi
application = create_app()