Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Merge branch 'Riverfount-1-AddDynaconf' into extended
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Aug 28, 2018
2 parents 7993115 + 93249af commit 276324d
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source = talkshow
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export FLASK_APP=talkshow/app.py
export FLASK_ENV=development
export FLASK_ENV=development

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
*env
venv
.venv
.talkshow
*.egg-info
database
.pytest_cache
__pycache__
*/__pycache__
.secrets.toml
.coverage
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ python:
- "3.6"
install:
- "pip install --upgrade pip"
- "pip install .[dev]"
- "pip install -e .[dev]"
script:
- "flake8 talkshow/"
- "flake8 tests/"
- "py.test --cov=talkshow -v tests/"
- "py.test -v --cov-config .coveragerc --cov=talkshow -l --tb=short --maxfail=1 tests/"
after_success: codecov
9 changes: 9 additions & 0 deletions settings.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[default]
DEBUG = true
SERVER = 'localhost'
PORT = 5000
FLASK_ADMIN_SWATCH = 'cerulean'
SECRET_KEY = 'empty'

[development]
DEBUG = true
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
from setuptools import setup
from setuptools import setup, find_packages

requirements = [
'flask',
Expand All @@ -11,7 +11,8 @@
'flask-restful',
'flask-bootstrap',
'python-dotenv',
'flasgger'
'flasgger',
'dynaconf'
]

requirements_extra = {
Expand All @@ -28,7 +29,7 @@
name='talkshow',
version='0.1.0',
description="Call for papers system",
packages=['talkshow'],
packages=find_packages(include=['talkshow', 'talkshow.*']),
include_package_data=True,
install_requires=requirements,
extras_require=requirements_extra
Expand Down
15 changes: 8 additions & 7 deletions talkshow/app.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from flask import Flask
from talkshow.ext import db
from talkshow.ext import cli
from talkshow.ext import bootstrap

from talkshow.blueprints import restapi
from talkshow.blueprints import webui
from talkshow.ext import admin
from talkshow.ext import apidocs
from talkshow.ext import bootstrap
from talkshow.ext import cli
from talkshow.ext import configuration
from talkshow.ext import db
from talkshow.ext import login
from talkshow.blueprints import webui
from talkshow.blueprints import restapi


def create_app():
"""Creates a new Flask app"""
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret'
app.config['FLASK_ADMIN_SWATCH'] = 'cerulean'
configuration.configure(app)
# extensions
db.configure(app) # <-- `app` passado para o db factory
cli.configure(app) # <-- `app` passado para o cli factory
Expand Down
8 changes: 8 additions & 0 deletions talkshow/ext/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dynaconf import FlaskDynaconf


def configure(app):
""" Initialize Dynaconf Extension
:param app: Instance of flask application
"""
FlaskDynaconf(app)
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from talkshow.app import create_app


@pytest.fixture(scope="module")
@pytest.fixture(scope='module')
def app():
"""Flask Pytest uses it"""
return create_app()


@pytest.fixture(scope="module")
@pytest.fixture(scope='module')
def auth():
"""The Basic Auth credentials for testing"""
credentials = b64encode(bytes("admin:1234", 'ascii')).decode('ascii')
Expand Down
14 changes: 14 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


def test_can_create_event(client, auth):
"""Asserts an event can be created via API"""
event_data = {"name": "Puggies Convention", "date": "2018-09-09"}
created = client.post('/api/v1/event/', json=event_data, headers=auth)
assert created.status_code == 201


def test_can_list_event(client):
"""Asserts event can be listed"""
events = client.get('/api/v1/event/')
assert events.status_code == 200
assert 'events' in events.json
16 changes: 0 additions & 16 deletions tests/test_apy.py

This file was deleted.

0 comments on commit 276324d

Please sign in to comment.