Make the app config more powerful in terms of injecting fake dependencies. Refactor the tests to use metaclasses and to actually all run.
This commit is contained in:
parent
2a849f631b
commit
2cd98fc58e
15 changed files with 669 additions and 511 deletions
|
@ -11,10 +11,7 @@ from flask.ext.principal import identity_changed, AnonymousIdentity
|
|||
from functools import wraps
|
||||
from collections import defaultdict
|
||||
|
||||
import storage
|
||||
|
||||
from data import model
|
||||
from data.userfiles import UserRequestFiles
|
||||
from data.queue import dockerfile_build_queue
|
||||
from data.plans import USER_PLANS, BUSINESS_PLANS, get_plan
|
||||
from app import app
|
||||
|
@ -33,7 +30,8 @@ from endpoints.web import common_login
|
|||
from util.cache import cache_control
|
||||
|
||||
|
||||
store = storage.load()
|
||||
store = app.config['STORAGE']
|
||||
user_files = app.config['USERFILES']
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -263,11 +261,6 @@ def get_matching_entities(prefix):
|
|||
})
|
||||
|
||||
|
||||
user_files = UserRequestFiles(app.config['AWS_ACCESS_KEY'],
|
||||
app.config['AWS_SECRET_KEY'],
|
||||
app.config['REGISTRY_S3_BUCKET'])
|
||||
|
||||
|
||||
def team_view(orgname, t):
|
||||
view_permission = ViewTeamPermission(orgname, t.name)
|
||||
role = model.get_team_org_role(t).name
|
||||
|
@ -454,6 +447,7 @@ def delete_organization_team_member(orgname, teamname, membername):
|
|||
|
||||
@app.route('/api/repository', methods=['POST'])
|
||||
@api_login_required
|
||||
@required_json_args('repository', 'visibility', 'description')
|
||||
def create_repo_api():
|
||||
owner = current_user.db_user()
|
||||
json = request.get_json()
|
||||
|
@ -468,7 +462,7 @@ def create_repo_api():
|
|||
if existing:
|
||||
return make_response('Repository already exists', 400)
|
||||
|
||||
visibility = request.get_json()['visibility']
|
||||
visibility = json['visibility']
|
||||
|
||||
repo = model.create_repository(namespace_name, repository_name, owner,
|
||||
visibility)
|
||||
|
@ -563,7 +557,7 @@ def update_repo_api(namespace, repository):
|
|||
'success': True
|
||||
})
|
||||
|
||||
abort(404)
|
||||
abort(403)
|
||||
|
||||
|
||||
@app.route('/api/repository/<path:repository>/changevisibility',
|
||||
|
@ -1107,6 +1101,7 @@ def subscription_view(stripe_subscription, used_repos):
|
|||
|
||||
@app.route('/api/user/plan', methods=['PUT'])
|
||||
@api_login_required
|
||||
@required_json_args('token', 'plan')
|
||||
def subscribe_api():
|
||||
request_data = request.get_json()
|
||||
plan = request_data['plan']
|
||||
|
|
Reference in a new issue