forked from containerbuildsystem/cachito
-
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.
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
- Loading branch information
Showing
19 changed files
with
115 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
all: run | ||
|
||
clean: | ||
rm -rf venv && rm -rf *.egg-info && rm -rf dist && rm -rf *.log* | ||
rm -rf venv && rm -rf *.egg-info && rm -rf dist && rm -rf *.log* && rm -rf .tox | ||
|
||
venv: | ||
virtualenv --python=python3 venv && venv/bin/python setup.py develop | ||
|
||
run: venv | ||
FLASK_APP=cachito CACHITO_SETTINGS=../settings.cfg venv/bin/flask run | ||
FLASK_APP=cachito/wsgi:app venv/bin/flask run | ||
|
||
test: venv | ||
CACHITO_SETTINGS=../settings.cfg venv/bin/python -m unittest discover -s tests | ||
|
||
sdist: venv test | ||
venv/bin/python setup.py sdist | ||
test: | ||
tox |
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 |
---|---|---|
@@ -1,17 +0,0 @@ | ||
import os | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
app.config.from_object('cachito.default_settings') | ||
app.config.from_envvar('CACHITO_SETTINGS') | ||
|
||
if not app.debug: | ||
import logging | ||
from logging.handlers import TimedRotatingFileHandler | ||
# https://docs.python.org/3.6/library/logging.handlers.html#timedrotatingfilehandler | ||
file_handler = TimedRotatingFileHandler(os.path.join(app.config['LOG_DIR'], 'cachito.log'), 'midnight') | ||
file_handler.setLevel(logging.WARNING) | ||
file_handler.setFormatter(logging.Formatter('<%(asctime)s> <%(levelname)s> %(message)s')) | ||
app.logger.addHandler(file_handler) | ||
|
||
import cachito.views | ||
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,10 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from flask import Blueprint, jsonify | ||
|
||
|
||
api_v1 = Blueprint('api_v1', __name__) | ||
|
||
|
||
@api_v1.route('/ping', methods=['GET']) | ||
def ping(): | ||
return jsonify(True) |
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,16 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from flask import Flask | ||
from cachito.splash import splash | ||
from cachito.api_v1 import api_v1 | ||
|
||
|
||
# See app factory pattern: | ||
# http://flask.pocoo.org/docs/0.12/patterns/appfactories/ | ||
def create_app(config_filename=None): | ||
app = Flask(__name__) | ||
if config_filename: | ||
app.config.from_pyfile(config_filename) | ||
|
||
app.register_blueprint(splash) | ||
app.register_blueprint(api_v1, url_prefix='/api/v1') | ||
return app |
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from flask import render_template, Blueprint | ||
|
||
|
||
splash = Blueprint('splash', __name__, static_folder='static', template_folder='template') | ||
|
||
|
||
@splash.route('/', methods=['GET']) | ||
def index(): | ||
return render_template('index.html') |
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 was deleted.
Oops, something went wrong.
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,5 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from cachito.app import create_app | ||
|
||
|
||
app = create_app() |
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 @@ | ||
-rrequirements.txt | ||
|
||
pytest |
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,4 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
|
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 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
import pytest | ||
|
||
|
||
from cachito.wsgi import create_app | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def client(): | ||
"""Return Flask application client for the pytest session.""" | ||
return create_app().test_client() |
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 @@ | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
import json | ||
|
||
|
||
def test_ping(client): | ||
rv = client.get('/api/v1/ping') | ||
assert json.loads(rv.data.decode('utf-8')) is True |
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
# # SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
|
||
def test_index(client): | ||
rv = client.get('/') | ||
assert 'Welcome to cachito' in rv.data.decode('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,25 @@ | ||
[tox] | ||
envlist = lint,py36 | ||
|
||
[testenv] | ||
deps = | ||
-rdev-requirements.txt | ||
whitelist_externals = | ||
make | ||
setenv = | ||
CACHITO_SETTINGS={toxinidir}/settings.cfg | ||
commands = | ||
py.test -vvv tests/ {posargs} | ||
|
||
[testenv:lint] | ||
deps = | ||
flake8 | ||
commands = | ||
python -m flake8 {posargs} | ||
|
||
[flake8] | ||
show-source = True | ||
max-line-length = 100 | ||
exclude = venv,.git,.tox,dist,*egg | ||
# W504 line break after binary operator | ||
ignore = W504 |