-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_messenger.py
More file actions
executable file
·40 lines (30 loc) · 1.03 KB
/
simple_messenger.py
File metadata and controls
executable file
·40 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from app import celery, create_app, database, socket_io
from app.models import add_test_users as add_users
from app.models import UserChatTable, Chat, RemovedChat
from app.models import User, Role, Contact, Message
from sqlalchemy.exc import IntegrityError
app = create_app()
@app.cli.command('add_test_users', help='Add test users to the database.')
def add_test_users():
try:
add_users()
except IntegrityError:
database.session.rollback()
return
@app.cli.command('test', help='Run all tests.')
def test_all():
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)
@app.shell_context_processor
def make_shell_context():
return {'database': database,
'UserChatTable': UserChatTable,
'Chat': Chat,
'User': User,
'Role': Role,
'RemovedChat': RemovedChat,
'Contact': Contact,
'Message': Message}
if __name__ == '__main__':
socket_io.run(app, debug=False)