forked from miguelgrinberg/microblog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8e9bfe
commit 8c091d7
Showing
10 changed files
with
140 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!-- extend base layout --> | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>File Not Found</h1> | ||
<p><a href="{{url_for('index')}}">Back</a></p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- extend base layout --> | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>An unexpected error has occurred</h1> | ||
<p>The administrator has been notified. Sorry for the inconvenience!</p> | ||
<p><a href="{{url_for('index')}}">Back</a></p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,13 @@ | |
{ 'name': 'MyOpenID', 'url': 'https://www.myopenid.com' }] | ||
|
||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db') | ||
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository') | ||
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository') | ||
|
||
# mail server settings | ||
MAIL_SERVER = 'localhost' | ||
MAIL_PORT = 25 | ||
MAIL_USERNAME = None | ||
MAIL_PASSWORD = None | ||
|
||
# administrator list | ||
ADMINS = ['[email protected]'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!flask/bin/python | ||
from app import app | ||
app.run(debug = False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!flask/bin/python | ||
import os | ||
import unittest | ||
|
||
from config import basedir | ||
from app import app, db | ||
from app.models import User | ||
|
||
class TestCase(unittest.TestCase): | ||
def setUp(self): | ||
app.config['TESTING'] = True | ||
app.config['CSRF_ENABLED'] = False | ||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db') | ||
db.create_all() | ||
|
||
def tearDown(self): | ||
db.drop_all() | ||
|
||
def test_avatar(self): | ||
# create a user | ||
u = User(nickname = 'john', email = '[email protected]') | ||
avatar = u.avatar(128) | ||
expected = 'http://www.gravatar.com/avatar/d4c74594d841139328695756648b6bd6' | ||
assert avatar[0:len(expected)] == expected | ||
|
||
def test_make_unique_nickname(self): | ||
# create a user and write it to the database | ||
u = User(nickname = 'john', email = '[email protected]') | ||
db.session.add(u) | ||
db.session.commit() | ||
nickname = User.make_unique_nickname('john') | ||
assert nickname != 'john' | ||
# make another user with the new nickname | ||
u = User(nickname = nickname, email = '[email protected]') | ||
db.session.add(u) | ||
db.session.commit() | ||
nickname2 = User.make_unique_nickname('john') | ||
assert nickname2 != 'john' | ||
assert nickname2 != nickname | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |