Ejemplo n.º 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()
Ejemplo n.º 2
0
from url_shortener import create_app


app = create_app()
Ejemplo n.º 3
0
from url_shortener import create_app
from url_shortener.extensions import db

print("Creating tables")

db.create_all(app=create_app())
Ejemplo n.º 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()
Ejemplo n.º 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'))
Ejemplo n.º 6
0
def test_config():
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
Ejemplo n.º 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)
Ejemplo n.º 8
0
def app():
    app = create_app('testing')
    app_context = app.app_context()
    app_context.push()
    yield app
    app_context.pop()