예제 #1
0
def test_sample_url():
    """This will create a dummy URL in the db and checks it"""
    flask_app=create_app(config_file='settings.py')
    context=flask_app.app_context()
    context.push()
    db.create_all()
    link=LinkUrl(original_url="https://google.com")
    db.session.add(link)
    db.session.commit()
    assert db
    db.drop_all()
예제 #2
0
파일: run.py 프로젝트: mdb571/URL-Shortener
from url_shortener import create_app


app = create_app()
예제 #3
0
from url_shortener import create_app
from url_shortener.extensions import db

print("Creating tables")

db.create_all(app=create_app())
예제 #4
0
import os
import redis
from rq import Connection, Queue, Worker
from url_shortener import create_app

redis_url = os.environ.get('REDISTOGO_URL') or 'redis://localhost:6379'

conn = redis.from_url(redis_url)
try:
    conn.ping()
except redis.ConnectionError as err:
    import sys
    sys.exit(0)

app = create_app(os.environ.get('FLAsK_CONFIG') or 'default')
app.app_context().push()

if __name__ == '__main__':
    with Connection(conn):
        worker = Worker(['default'], connection=conn, name='db_cleaner')
        worker.work()
예제 #5
0
 def setUp(self):
     self.app = create_app(config_file='tests/test_settings.py').test_client()
     db.create_all(app=create_app(config_file='tests/test_settings.py'))
예제 #6
0
def test_config():
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
예제 #7
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     self.client = self.app.test_client(use_cookies=False)
예제 #8
0
def app():
    app = create_app('testing')
    app_context = app.app_context()
    app_context.push()
    yield app
    app_context.pop()