Beispiel #1
0
    def test_init_app(self):
        tweepy = Tweepy()

        self.app.config['TWEEPY_CONSUMER_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_CONSUMER_SECRET'] = 'secretsecret'
        self.app.config['TWEEPY_ACCESS_TOKEN_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_ACCESS_TOKEN_SECRET'] = 'secretsecret'

        tweepy.init_app(self.app)
        assert tweepy.api is not None
Beispiel #2
0
    def test_init_app(self):
        tweepy = Tweepy()

        self.app.config['TWEEPY_CONSUMER_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_CONSUMER_SECRET'] = 'secretsecret'
        self.app.config['TWEEPY_ACCESS_TOKEN_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_ACCESS_TOKEN_SECRET'] = 'secretsecret'

        tweepy.init_app(self.app)
        assert tweepy.api is not None
Beispiel #3
0
    def test_fails_with_duplicate_config_prefix(self):
        self.app.config['TWEEPY_CONSUMER_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_CONSUMER_SECRET'] = 'secretsecret'
        self.app.config['TWEEPY_ACCESS_TOKEN_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_ACCESS_TOKEN_SECRET'] = 'secretsecret'

        Tweepy(self.app)
        self.assertRaises(Exception, Tweepy, self.app)
Beispiel #4
0
    def test_custom_config_prefix(self):
        self.app.config['CUSTOM_CONSUMER_KEY'] = 'keykeykey'
        self.app.config['CUSTOM_CONSUMER_SECRET'] = 'secretsecret'
        self.app.config['CUSTOM_ACCESS_TOKEN_KEY'] = 'keykeykey'
        self.app.config['CUSTOM_ACCESS_TOKEN_SECRET'] = 'secretsecret'

        tweepy = Tweepy(self.app, config_prefix='CUSTOM')
        assert tweepy.api is not None
Beispiel #5
0
    def test_default_config_prefix(self):
        self.app.config['TWEEPY_CONSUMER_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_CONSUMER_SECRET'] = 'secretsecret'
        self.app.config['TWEEPY_ACCESS_TOKEN_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_ACCESS_TOKEN_SECRET'] = 'secretsecret'

        tweepy = Tweepy(self.app)
        assert tweepy.api is not None
Beispiel #6
0
    def test_multiple_tweepys(self):
        self.app.config['TWEEPY_CONSUMER_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_CONSUMER_SECRET'] = 'secretsecret'
        self.app.config['TWEEPY_ACCESS_TOKEN_KEY'] = 'keykeykey'
        self.app.config['TWEEPY_ACCESS_TOKEN_SECRET'] = 'secretsecret'

        tweepy1 = Tweepy(self.app)
        assert tweepy1.api is not None

        self.app.config['CUSTOM_CONSUMER_KEY'] = 'keykeykey'
        self.app.config['CUSTOM_CONSUMER_SECRET'] = 'secretsecret'
        self.app.config['CUSTOM_ACCESS_TOKEN_KEY'] = 'keykeykey'
        self.app.config['CUSTOM_ACCESS_TOKEN_SECRET'] = 'secretsecret'

        tweepy2 = Tweepy(self.app, config_prefix='CUSTOM')
        assert tweepy2.api is not None

        assert tweepy1.api is not tweepy2.api
Beispiel #7
0
__all__ = ('app', 'twitter', 'mongo')

from flask import Flask
from flask.ext.tweepy import Tweepy
from flask.ext.pymongo import PyMongo
from os.path import abspath, dirname, exists, join

app = Flask(__name__)

here = dirname(__file__)
parent = abspath(join(dirname(__file__), '..'))

config = join(parent, 'pyq.cfg')
if exists(config):
    app.config.from_pyfile(config)

private = join(parent, 'private.pyq.cfg')
if exists(private):
    app.config.from_pyfile(private)

twitter = Tweepy(app)
mongo = PyMongo(app)

import pythonquestions.views

Beispiel #8
0
    def test_api_is_none_if_unconfigured(self):
        tweepy = Tweepy()

        assert tweepy.api is None