Пример #1
0
    def setUp(self):
        app = create_app('testing')
        self.context = app.test_request_context()
        self.context.push()
        self.client = app.test_client()
        self.runner = app.test_cli_runner()

        db.create_all()
        Role.init_role()

        admin_user = User(email='*****@*****.**',
                          name='Admin',
                          username='******',
                          confirmed=True)
        admin_user.set_password('123')
        normal_user = User(email='*****@*****.**',
                           name='Normal User',
                           username='******',
                           confirmed=True)
        normal_user.set_password('123')
        unconfirmed_user = User(email='*****@*****.**',
                                name='unconfirmed',
                                username='******',
                                confirmed=False)
        unconfirmed_user.set_password('123')
        locked_user = User(email='*****@*****.**',
                           name='Locked User',
                           username='******',
                           confirmed=True,
                           locked=True)
        locked_user.set_password('123')
        locked_user.lock()
        blocked_user = User(email='*****@*****.**',
                            name='Blocked User',
                            username='******',
                            confirmed=True,
                            active=False)
        blocked_user.set_password('123')

        photo = Photo(filename='test.jpg',
                      filename_s='test_s.jpg',
                      filename_m='test_m.jpg',
                      description='Photo 1',
                      author=admin_user)
        photo2 = Photo(filename='test2.jpg',
                       filename_s='test_s2.jpg',
                       filename_m='test_m2.jpg',
                       description='Photo 2',
                       author=normal_user)

        comment = Comment(body='test comment body',
                          photo=photo,
                          author=normal_user)
        tag = Tag(name='test tag')
        photo.tags.append(tag)
        db.session.add_all([
            admin_user, normal_user, unconfirmed_user, locked_user,
            blocked_user
        ])
        db.session.commit()
Пример #2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from albumy import create_app
app = create_app()
app.run()
Пример #3
0
# -*- coding: utf-8 -*-
"""
    Created by 亥虫 on 2019/7/6
"""
import os
from dotenv import load_dotenv

dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
if os.path.exists(dotenv_path):
    load_dotenv(dotenv_path)

from albumy import create_app
app = create_app('production')
Пример #4
0
import os
from dotenv import load_dotenv


dotenv_path = os.path.join(os.path.dirname(__file__), ".env")


if os.path.exists(dotenv_path):
    load_dotenv(dotenv_path)


from albumy import create_app
app = create_app("production")
Пример #5
0
    def setUp(self) -> None:
        app = create_app('testing')
        self.context = app.test_request_context()
        self.context.push()
        self.client = app.test_client()
        self.runner = app.test_cli_runner()

        db.create_all()
        Role.init_role()

        admin_user = User(email='*****@*****.**',
                          name='Admin',
                          username='******',
                          confirmed=True)
        admin_user.password = '******'

        normal_user = User(email='*****@*****.**',
                           name='Normal',
                           username='******',
                           confirmed=True)
        normal_user.password = '******'

        unconfirm_user = User(email='*****@*****.**',
                              name='Unconfirm',
                              username='******',
                              confirmed=False)
        unconfirm_user.password = '******'

        locked_user = User(email='*****@*****.**',
                           name='Locked',
                           username='******',
                           confirmed=True,
                           locked=True)
        locked_role = Role.query.filter_by(name='Locked').first()
        locked_user.role = locked_role
        locked_user.password = '******'

        block_user = User(email='*****@*****.**',
                          name='Block',
                          username='******',
                          confirmed=True,
                          active=False)
        block_user.password = '******'

        photo = Photo(filename='test.jpg',
                      filename_s='test_s.jpg',
                      filename_m='test_m.jpg',
                      author=admin_user,
                      description='Photo 1')
        photo2 = Photo(filename='test2.jpg',
                       filename_s='test2_s.jpg',
                       filename_m='test2_m.jpg',
                       author=normal_user,
                       description='Photo 2')

        comment = Comment(body='test comment body',
                          photo=photo,
                          author=normal_user)
        tag = Tag(name='test tag')
        photo.tags.append(tag)
        db.session.add_all([
            admin_user, normal_user, unconfirm_user, locked_user, block_user,
            photo, photo2, comment, tag
        ])
        db.session.commit()