-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mnaile/master
added tests modified structure
- Loading branch information
Showing
13 changed files
with
271 additions
and
16 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 |
---|---|---|
|
@@ -6,7 +6,7 @@ __pycache__/ | |
# C extensions | ||
*.so | ||
.vscode/ | ||
|
||
mytest.py | ||
# Distribution / packaging | ||
.Python | ||
build/ | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
db_conf = """ | ||
from flask import current_app | ||
from extensions.extensions import db | ||
from sqlalchemy.dialects.postgresql import UUID | ||
from uuid import uuid4 | ||
from datetime import datetime | ||
from sqlalchemy.orm import relationship | ||
Integer, Column, String, DateTime, Boolean, Date, relationship, ForeignKey = db.Integer, db.Column, db.String, db.DateTime, db.Boolean, db.Date, db.relationship, db.ForeignKey | ||
class Operation: | ||
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid4) | ||
created_at = Column(DateTime(timezone=True), default=datetime.utcnow, server_default=db.func.now()) | ||
updated_at = Column(DateTime(timezone=True),default=datetime.utcnow,onupdate=datetime.utcnow,server_default=db.func.now()) | ||
class Model(db.Model, Operation): | ||
__abstract__= True | ||
def save_db(self): | ||
try: | ||
db.session.add(self) | ||
db.session.commit() | ||
return self | ||
except Exception as err: | ||
current_app.logger.error(err) | ||
return False | ||
def delete_from_db(self): | ||
try: | ||
db.session.delete(self) | ||
db.session.commit() | ||
return self | ||
except Exception as err: | ||
current_app.logger.error(err) | ||
return False | ||
def update_db(self, **kwargs): | ||
try: | ||
for key, val in kwargs.items(): | ||
setattr(self, key, val) | ||
self.save_db() | ||
except Exception as err: | ||
current_app.logger.error(err) | ||
return False | ||
""" |
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 @@ | ||
env = """ | ||
export FLASK_APP=server | ||
export FLASK_ENV=development | ||
export settings=dev | ||
#export FLASK_ENV=prodaction | ||
#export settings=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
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,7 +1,17 @@ | ||
flask_model =''' | ||
from extensions.extension import Model,String,Integer,Column,DateTime,ForeignKey,relationship | ||
from extensions.extension import db | ||
from sqlalchemy.sql import func | ||
from sqlalchemy.exc import InvalidRequestError,IntegrityError | ||
from extensions.db_conf import ( | ||
Model, | ||
DateTime, | ||
Integer, | ||
String, | ||
Column, | ||
Boolean, | ||
Date, | ||
relationship, | ||
ForeignKey, | ||
) | ||
''' |
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,23 @@ | ||
server = """ | ||
import os | ||
from werkzeug.middleware.dispatcher import DispatcherMiddleware | ||
from werkzeug.serving import run_simple | ||
from app_init.app_factory import create_app | ||
if os.environ["settings"]: | ||
settings_name = os.environ["settings"] | ||
else: | ||
raise Exception("'settings' environment " "variable is not defined") | ||
flask_app = create_app(settings_name) | ||
app = DispatcherMiddleware(flask_app) | ||
if __name__ == "__main__": | ||
run_simple("127.0.0.1", 8000, app, use_debugger=True, threaded=True) | ||
""" |
Oops, something went wrong.