-
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.
Initial commit with project base. Already dockerized. Project's test setup configured.
- Loading branch information
0 parents
commit b0fd486
Showing
13 changed files
with
170 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
env | ||
.dockerignore | ||
Dockerfile-dev | ||
Dockerfile-prod |
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 @@ | ||
__pycache__ | ||
env | ||
.vscode/ |
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,15 @@ | ||
# Base Image | ||
FROM python:3.6.5-alpine | ||
|
||
# Setting working directory | ||
WORKDIR /app | ||
|
||
# Dealing with requirements | ||
COPY ./requirements.txt /app/requirements.txt | ||
RUN pip install -r requirements.txt | ||
|
||
# Coping project | ||
COPY . /app | ||
|
||
# Running server | ||
CMD python manage.py run -h 0.0.0.0 |
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,26 @@ | ||
# Configurando o ambiente | ||
Para instruções de como instalar o Docker e o Docker-compose clique [aqui](https://github.com/Kalkuli/2018.2-Kalkuli_Front-End/blob/master/README.md). | ||
|
||
|
||
<br> | ||
|
||
## Colocando no ar | ||
Com o Docker e Docker-Compose instalados, basta apenas utilizar os comandos: | ||
|
||
```docker-compose -f docker-compose-dev.yml build``` | ||
|
||
e | ||
|
||
```docker-compose -f docker-compose-dev.yml up``` | ||
|
||
Acesse o servidor local no endereço apresentado abaixo: | ||
|
||
http://localhost:5002/ | ||
|
||
|
||
Agora você já pode começar a contribuir! | ||
|
||
|
||
## Testando | ||
|
||
```docker-compose -f docker-compose-dev.yml run base python manage.py test``` |
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,14 @@ | ||
version: '3.6' | ||
services: | ||
base: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile-dev | ||
volumes: | ||
- '.:/app' | ||
ports: | ||
- 5007:5000 | ||
environment: | ||
- FLASK_APP=project/__init__.py | ||
- FLASK_ENV=development | ||
- APP_SETTINGS=project.config.DevelopmentConfig |
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,20 @@ | ||
from flask.cli import FlaskGroup | ||
from project import app | ||
import unittest | ||
|
||
cli = FlaskGroup(app) | ||
|
||
|
||
# Registers comand to run tests | ||
@cli.command() | ||
def test(): | ||
tests = unittest.TestLoader().discover('project/tests', pattern='test*.py') | ||
result = unittest.TextTestRunner(verbosity=2).run(tests) | ||
if result.wasSuccessful(): | ||
return 0 | ||
return 1 | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
cli() |
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,15 @@ | ||
import os | ||
from flask import Flask, jsonify | ||
|
||
# Instantiate the app | ||
app = Flask(__name__) | ||
|
||
# Set Configuration | ||
app_settings = os.getenv('APP_SETTINGS') | ||
app.config.from_object(app_settings) | ||
|
||
@app.route('/', methods=['GET']) | ||
def ping_pong(): | ||
return jsonify({ | ||
'data': 'Welcome to Kalkuli Exporter!' | ||
}) |
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,12 @@ | ||
class BaseConfig: | ||
TESTING = False | ||
|
||
class DevelopmentConfig(BaseConfig): | ||
THIS = 'Development' | ||
|
||
class TestingConfig(BaseConfig): | ||
TESTING = True | ||
THIS = 'Testing' | ||
|
||
class ProductionConfig(BaseConfig): | ||
THIS = 'Production' |
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,16 @@ | ||
from flask_testing import TestCase | ||
from project import app, db | ||
|
||
class BaseTestCase(TestCase): | ||
|
||
def create_app(self): | ||
app.config.from_object('project.config.TestingConfig') | ||
return app | ||
|
||
def setUp(self): | ||
db.create_all() | ||
db.session.commit() | ||
|
||
def tearDown(self): | ||
db.session.remove() | ||
db.drop_all() |
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,43 @@ | ||
import os | ||
import unittest | ||
from flask import current_app | ||
from flask_testing import TestCase | ||
from project import app | ||
|
||
class TestDevelopmentConfig(TestCase): | ||
def create_app(self): | ||
app.config.from_object('project.config.DevelopmentConfig') | ||
return app | ||
|
||
def test_app_is_development(self): | ||
self.assertFalse(current_app is None) | ||
self.assertTrue( | ||
app.config['THIS'] == 'Development' | ||
) | ||
|
||
|
||
class TestTestingConfig(TestCase): | ||
def create_app(self): | ||
app.config.from_object('project.config.TestingConfig') | ||
return app | ||
|
||
def test_app_is_testing(self): | ||
self.assertTrue(app.config['TESTING']) | ||
self.assertFalse(app.config['PRESERVE_CONTEXT_ON_EXCEPTION']) | ||
self.assertTrue( | ||
app.config['THIS'] == 'Testing' | ||
) | ||
|
||
|
||
class TestProductionConfig(TestCase): | ||
def create_app(self): | ||
app.config.from_object('project.config.ProductionConfig') | ||
return app | ||
|
||
def test_app_is_production(self): | ||
self.assertFalse(app.config['TESTING']) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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 @@ | ||
Flask==1.0.2 | ||
Flask-Testing==0.6.2 |