Skip to content

Commit

Permalink
Fixed BDD testing + almost completed
Browse files Browse the repository at this point in the history
  • Loading branch information
cisc0f committed Apr 27, 2024
1 parent c5d31dd commit da52b4e
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 250 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NYU DevOps Project Template

[![CI Build](https://github.com/CSCI-GA-2820-SP24-003/shopcarts/actions/workflows/ci.yml/badge.svg)](https://github.com/CSCI-GA-2820-SP24-003/shopcarts/actions/workflows/ci.yml)
[![CI Build](https://github.com/CSCI-GA-2820-SP24-003/shopcarts/actions/workflows/ci.yml/badge.svg)](https://github.com/CSCI-GA-2820-SP24-003/shopcarts/actions/workflows/tdd.yml)
[![codecov](https://codecov.io/gh/CSCI-GA-2820-SP24-003/shopcarts/graph/badge.svg?token=MM379ZQE9D)](https://codecov.io/gh/CSCI-GA-2820-SP24-003/shopcarts)

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Expand Down
3 changes: 2 additions & 1 deletion features/steps/shopcarts_steps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# spell: ignore shopcarts shopcart
"""
Shopcart Steps
Expand All @@ -19,7 +20,7 @@ def step_impl(context):
""" Delete all shopcarts and load new ones """

# List all of the shopcarts and delete them one by one
rest_endpoint = f"{context.base_url}/shopcarts"
rest_endpoint = f"{context.base_url}/api/shopcarts"
context.resp = requests.get(rest_endpoint)
assert(context.resp.status_code == HTTP_200_OK)
for shopcart in context.resp.json():
Expand Down
20 changes: 6 additions & 14 deletions service/common/error_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
Module: error_handlers
"""
from service import api
from flask import jsonify
from flask import current_app as app # Import Flask application
from service.models import DataValidationError
from . import status
Expand All @@ -29,17 +28,10 @@
@api.errorhandler(DataValidationError)
def request_validation_error(error):
"""Handles Value Errors from bad data"""
return bad_request(error)


@app.errorhandler(status.HTTP_400_BAD_REQUEST)
def bad_request(error):
"""Handles bad requests with 400_BAD_REQUEST"""
message = str(error)
app.logger.warning(message)
return (
jsonify(
status=status.HTTP_400_BAD_REQUEST, error="Bad Request", message=message
),
status.HTTP_400_BAD_REQUEST,
)
app.logger.error(message)
return {
"status_code": status.HTTP_400_BAD_REQUEST,
"error": "Bad Request",
"message": message,
}, status.HTTP_400_BAD_REQUEST
4 changes: 2 additions & 2 deletions service/models/shop_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def serialize(self) -> dict:
"id": self.id,
"user_id": self.user_id,
"name": self.name,
"total_price": self.total_price,
"total_price": float(self.total_price),
"status": self.status.name,
"items": [],
}
Expand Down Expand Up @@ -151,5 +151,5 @@ def find_by_status(cls, status):
Args:
status (ShopCartStatus): the status of the ShopCarts you want to match
"""
logger.info("Processing status query for %s ...", status.name)
logger.info("Processing status query for %s ...", status)
return cls.query.filter(cls.status == status).all()
2 changes: 1 addition & 1 deletion service/models/shop_cart_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def serialize(self) -> dict:
"name": self.name,
"product_id": self.product_id,
"quantity": self.quantity,
"price": self.price,
"price": float(self.price),
}

def deserialize(self, data):
Expand Down
Loading

0 comments on commit da52b4e

Please sign in to comment.