Skip to content

Commit

Permalink
Removed commens, formatted files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsilk committed Aug 8, 2022
1 parent 807cf42 commit 7549091
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion extensions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()
db = SQLAlchemy()
2 changes: 0 additions & 2 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# creates SQLALCHEMY object
import jwt
from flask import json
from flask_bcrypt import generate_password_hash
Expand Down Expand Up @@ -62,7 +61,6 @@ def password(self, plaintext):

class Product(db.Model, SerializerMixin):
serialize_rules = ('-products.user',)
# serialize_rules = ('-products.user', '-seller')

id = db.Column(db.Integer, primary_key=True)
amount_available = db.Column(db.Integer)
Expand Down
16 changes: 7 additions & 9 deletions test_fill_database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sqlalchemy
from models import User
from models import User, Product, Role

from extensions import db
from main import create_app
Expand All @@ -12,7 +12,6 @@ def create_tables(db):


def fill_db_test(db):
from models import User, Product, Role

user1 = User(username='user1', password='pass1')
user2 = User(username='user2', password='pass2')
Expand Down Expand Up @@ -45,8 +44,6 @@ def test_cost_constraint():
of 5. Will throw an IntegrityError.
"""

from models import db, Product

user = db.session.query(User).all()[0]

user.products.append(Product(productName='p1', amountAvailable=10, cost=6, sellerID=user))
Expand All @@ -57,8 +54,9 @@ def test_cost_constraint():
logger.info("Test passed, cost can only be multiples of 5.")


app = create_app()
db.init_app(app)
with app.app_context():
create_tables(db)
fill_db_test(db)
if __name__ == '__main__':
app = create_app()
db.init_app(app)
with app.app_context():
create_tables(db)
fill_db_test(db)

0 comments on commit 7549091

Please sign in to comment.