This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Testing environment bootstrapping #53
Merged
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
853f927
Added setup.cfg for tests
miteshashar 71f5372
Without reloading sys, sys.setdefaultencoding() isnt available in tes…
miteshashar dcfe2c2
Merge branch 'crudapi' into crudapi-mitesh
miteshashar 1ce6fa1
nosetests will only check the tests directory for tests.
miteshashar 73ed609
Bootstrapping the testing environment. Basic fixtures in place.
miteshashar 32e76fa
Committed the db session in make_fixtures()
miteshashar 68d283e
Using db.app = app removes dependency on test_request_context(). Spec…
miteshashar 291b743
Added .travis.yml & test_requirements.txt
miteshashar 2a447b1
s/LastuserTest/TestDatabaseFixture
miteshashar daff243
Adding the users was not supposed to be removed. Removed it while rem…
miteshashar 49040e3
Removed dummy test.
miteshashar a7be390
Newline required at end of all files.
miteshashar fbd7654
tests should cover all three lastuser blueprints
miteshashar 4f8977a
Using spaces for indentation.
miteshashar 252ac96
Call reload(sys) in sitecustomize, only when setdefaultencoding is no…
miteshashar d1e9d79
Upgrade for Flask-WTF 0.9.0 imports.
jace 41c88c8
Merge branch 'master' into crudapi-mitesh
miteshashar 82fc2e7
Added pypy to .travis.yml
miteshashar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: python | ||
python: | ||
- 2.7 | ||
install: | ||
- pip install -r requirements.txt --use-mirrors | ||
- pip install -r test_requirements.txt --use-mirrors | ||
script: | ||
- nosetests tests --with-coverage | ||
notifications: | ||
email: false | ||
irc: "irc.freenode.net#hasgeek-dev" |
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,101 @@ | ||
# -*- coding: utf-8 -*- | ||
from flask import Markup | ||
|
||
#: The title of this site | ||
SITE_TITLE = 'Lastuser' | ||
|
||
#: Support contact email | ||
SITE_SUPPORT_EMAIL = 'test@example.com' | ||
|
||
#: TypeKit code for fonts | ||
TYPEKIT_CODE = '' | ||
|
||
#: Google Analytics code UA-XXXXXX-X | ||
GA_CODE = '' | ||
|
||
#: Database backend | ||
SQLALCHEMY_BINDS = { | ||
'lastuser': 'postgresql://postgres@localhost/myapp_test', | ||
} | ||
|
||
#: Cache type | ||
CACHE_TYPE = 'redis' | ||
|
||
#: Secret key | ||
SECRET_KEY = 'random_string_here' | ||
|
||
#: Timezone | ||
TIMEZONE = 'Asia/Calcutta' | ||
|
||
#: Reserved usernames | ||
#: Add to this list but do not remove any unless you want to break | ||
#: the website | ||
RESERVED_USERNAMES = set([ | ||
'app', | ||
'apps', | ||
'auth', | ||
'client', | ||
'confirm', | ||
'login', | ||
'logout', | ||
'new', | ||
'profile', | ||
'reset', | ||
'register', | ||
'token', | ||
'organizations', | ||
]) | ||
|
||
#: Mail settings | ||
#: MAIL_FAIL_SILENTLY : default True | ||
#: MAIL_SERVER : default 'localhost' | ||
#: MAIL_PORT : default 25 | ||
#: MAIL_USE_TLS : default False | ||
#: MAIL_USE_SSL : default False | ||
#: MAIL_USERNAME : default None | ||
#: MAIL_PASSWORD : default None | ||
#: DEFAULT_MAIL_SENDER : default None | ||
MAIL_FAIL_SILENTLY = False | ||
MAIL_SERVER = 'localhost' | ||
DEFAULT_MAIL_SENDER = ('Lastuser', 'test@example.com') | ||
MAIL_DEFAULT_SENDER = DEFAULT_MAIL_SENDER # For new versions of Flask-Mail | ||
|
||
#: Logging: recipients of error emails | ||
ADMINS = [] | ||
|
||
#: Log file | ||
LOGFILE = 'error.log' | ||
|
||
#: Use SSL for some URLs | ||
USE_SSL = False | ||
|
||
#: Twitter integration | ||
OAUTH_TWITTER_KEY = '' | ||
OAUTH_TWITTER_SECRET = '' | ||
|
||
#: GitHub integration | ||
OAUTH_GITHUB_KEY = '' | ||
OAUTH_GITHUB_SECRET = '' | ||
|
||
#: Recaptcha for the registration form | ||
RECAPTCHA_USE_SSL = USE_SSL | ||
RECAPTCHA_PUBLIC_KEY = '' | ||
RECAPTCHA_PRIVATE_KEY = '' | ||
RECAPTCHA_OPTIONS = '' | ||
|
||
#: SMS gateways | ||
SMS_SMSGUPSHUP_MASK = '' | ||
SMS_SMSGUPSHUP_USER = '' | ||
SMS_SMSGUPSHUP_PASS = '' | ||
|
||
#: Messages (text or HTML) | ||
MESSAGE_FOOTER = Markup('Copyright © <a href="http://hasgeek.com/">HasGeek</a>. Powered by <a href="https://github.com/hasgeek/lastuser" title="GitHub project page">Lastuser</a>, open source software from <a href="https://github.com/hasgeek">HasGeek</a>.') | ||
USERNAME_REASON = '' | ||
EMAIL_REASON = 'Please provide an email address to complete your profile' | ||
BIO_REASON = '' | ||
TIMEZONE_REASON = 'Dates and times will be shown in your preferred timezone' | ||
ORG_NAME_REASON = u"Your company’s name as it will appear in the URL. Letters, numbers and dashes only" | ||
ORG_TITLE_REASON = u"Your organization’s given name, preferably without legal suffixes" | ||
ORG_DESCRIPTION_REASON = u"A few words about your organization (optional). Plain text only" | ||
LOGIN_MESSAGE_1 = "" | ||
LOGIN_MESSAGE_2 = "" |
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 @@ | ||
[nosetests] | ||
match=^test | ||
nocapture=1 | ||
cover-package=lastuser_core, lastuser_oauth, lastuser_ui | ||
with-coverage=1 | ||
cover-erase=1 | ||
with-doctest=1 | ||
where=tests |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Required to make OpenID work with Wordpress (first instance where it came up) | ||
import sys | ||
if not hasttr(sys, 'setdefaultencoding'): | ||
reload(sys) | ||
sys.setdefaultencoding("utf-8") |
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,2 @@ | ||
nose | ||
coverage |
Empty file.
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,31 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from coaster import buid | ||
from lastuserapp import db, app | ||
from lastuser_core.models import * | ||
|
||
def make_fixtures(): | ||
user1 = User(username=u"user1", fullname=u"User 1") | ||
user2 = User(username=u"user2", fullname=u"User 2") | ||
db.session.add_all([user1, user2]) | ||
|
||
email1 = UserEmail(email=u"user1@example.com", user=user1) | ||
phone1 = UserPhone(phone=u"1234567890", user=user1) | ||
email2 = UserEmail(email=u"user2@example.com", user=user2) | ||
phone2 = UserPhone(phone=u"1234567891", user=user2) | ||
db.session.add_all([email1, phone1, email2, phone2]) | ||
|
||
org = Organization(name=u"org", title=u"Organization") | ||
org.owners.users.append(user1) | ||
db.session.add(org) | ||
|
||
client = Client(title=u"Test Application", org=org, user=user1, website=u"http://example.com") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, it doesn't fail because SQL doesn't allow one to apply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction: SQL does have the |
||
db.session.add(client) | ||
|
||
resource = Resource(name=u"test_resource", title=u"Test Resource", client=client) | ||
db.session.add(resource) | ||
|
||
action = ResourceAction(name=u"read", title=u"Read", resource=resource) | ||
db.session.add(action) | ||
|
||
db.session.commit() |
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,18 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import unittest | ||
from lastuserapp import app, db, init_for | ||
from .fixtures import make_fixtures | ||
|
||
class TestDatabaseFixture(unittest.TestCase): | ||
def setUp(self): | ||
init_for('testing') | ||
app.config['TESTING'] = True | ||
db.app = app | ||
db.drop_all() | ||
db.create_all() | ||
self.db = db | ||
make_fixtures() | ||
|
||
def tearDown(self): | ||
self.db.drop_all() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
pypy
as a build target. Lastuser fails under pypy for some reason. We have to figure it out.