Skip to content

Commit

Permalink
pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akrakman committed Oct 24, 2022
1 parent dc7b373 commit 4c680eb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

CORS(app)


@app.route("/login", methods=["POST", "GET"])
def login():
"""Handles login routing"""
Expand All @@ -36,6 +37,7 @@ def register():
return result.message, 400
return result.message, 200


@app.route("/", methods=["POST", "GET"])
@app.route("/home", methods=["POST", "GET"])
def home():
Expand All @@ -51,19 +53,19 @@ def home():
print(type(example), example)
json_string = apt_schema.dumps(example, many=True)
print(json_string)
#pics = mainpage.get_apartments_pictures(len(apts))
# pics = mainpage.get_apartments_pictures(len(apts))
if not selected:
apts = mainpage.apartments_default(len(apts))
return "success", 200
if ("low-high" in selected and "most popular" in selected) or (
"low-high" in selected and "high-low" in selected and
"most popular" in selected): # if both prices pressed it will sort low-high
"low-high" in selected and "high-low" in selected and "most popular" in selected
): # if both prices pressed it will sort low-high
apts = mainpage.apartments_sorted(len(apts), -1, -1)
elif "high-low" in selected and "most popular" in selected:
apts = mainpage.apartments_sorted(len(apts), 1, -1)
elif "most popular" in selected:
apts = mainpage.apartments_sorted(len(apts), 1, 0)
elif "low-high" in selected: # if both prices pressed it will sort low-high
elif "low-high" in selected: # if both prices pressed it will sort low-high
apts = mainpage.apartments_sorted(len(apts), -1, 0)
elif "high-low" in selected:
apts = mainpage.apartments_sorted(len(apts), 1, 0)
Expand Down
6 changes: 5 additions & 1 deletion src/backend/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from dataclasses import dataclass
from marshmallow import Schema, fields


@dataclass
class Apt:
"""Apt class, stores detail about an apartment"""
Expand All @@ -13,12 +14,15 @@ class Apt:
price_min: int
price_max: int


class ObjectSchema(Schema):
"""schema for serializing the Apartment JSON"""

apt_id = fields.Int()
name = fields.Str()
address = fields.Str()
review = fields.Str()
image = fields.Str()
rating = fields.Int()
price_min = fields.Int()
price_max = fields.Int()
price_max = fields.Int()
3 changes: 2 additions & 1 deletion src/backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pytest==7.1.3
pylint==2.15.2
coverage==6.4.4
black==22.8.0
marshmallow==3.14.1
marshmallow==3.14.1
flask_cors==1.10.3
7 changes: 4 additions & 3 deletions src/backend/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,22 @@ def test_login_invalid(client):
res = client.post("/login", json=log_info)
assert res.status_code == 404


def test_query_invalid(client):
"""A query is invalid when a query is empty"""
query_info = {"q": "", "selected": []}
res = client.post("/home", json=query_info)
assert res.status_code == 400


def test_query_none_selected(client):
"""Test query"""
connection = sqlite3.connect("database/database.db")
cursor = connection.cursor()
cursor.execute(
"INSERT INTO Apartments (apt_name, apt_address, price_min, price_max, link) \
"INSERT INTO Apartments (apt_name, apt_address, price_min, price_max, link) \
VALUES (?, ?, ?, ?, ?)",
("smile", "909 S 5th St", 5500, 6500, ""),
("smile", "909 S 5th St", 5500, 6500, ""),
)
connection.commit()
query_info = {"q": "smile", "selected": []}
Expand All @@ -108,4 +110,3 @@ def test_query_none_selected(client):
connection.commit()
connection.close()
assert res.status_code == 200

3 comments on commit 4c680eb

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py561180%60–72
TOTAL2021195% 

Tests Skipped Failures Errors Time
36 0 💤 0 ❌ 0 🔥 0.525s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py564814%16–102
login.py372532%26–58, 62–70
mainpage.py836818%17–34, 38–53, 60–76, 82–97, 103–118, 125–145, 149–158, 162–176
TOTAL20214130% 

Tests Skipped Failures Errors Time
1 0 💤 0 ❌ 1 🔥 0.480s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py561180%60–72
TOTAL2021195% 

Tests Skipped Failures Errors Time
36 0 💤 0 ❌ 0 🔥 0.602s ⏱️

Please sign in to comment.