-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
115 additions
and
111 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
python 3.11.3 | ||
kubectl 1.26.2 |
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 was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,36 @@ | ||
from typing import List, Dict, Callable, Any, Tuple | ||
from dataclasses import dataclass, field | ||
from result import Ok, Err, Result | ||
from pydantic import BaseModel | ||
from datetime import datetime | ||
from app.core import InvalidItemException, CustomException | ||
|
||
class CartItemIn(BaseModel): | ||
name: str | ||
price: int | ||
manufacturer: str | ||
|
||
class CartItem(BaseModel): | ||
id: str | ||
name: str | ||
price: int | ||
manufacturer: str | ||
created_at: datetime | ||
last_modified_at: datetime | ||
|
||
def validate_cart_item(item: CartItemIn) -> Result[CartItemIn, CustomException]: | ||
errors = [] | ||
|
||
if not item.name or len(item.name) == 0: | ||
errors.append("'name' must not be empty") | ||
|
||
if item.price is None or int(item.price) < 99: | ||
errors.append("'price' must be a non-empty number greater than 99") | ||
|
||
if not item.manufacturer or len(item.manufacturer) == 0: | ||
errors.append("'manufacturer' must not be empty") | ||
|
||
if errors: | ||
return Err(InvalidItemException(errors)) | ||
else: | ||
return Ok(item) |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from api.core.repository import Repository | ||
from api.core.service import Service | ||
from api.core.exceptions import (\ | ||
from app.core.repository import Repository | ||
from app.core.service import Service | ||
from app.core.exceptions import (\ | ||
CustomException, \ | ||
DBConnectionFailedException, \ | ||
NotFoundException, \ | ||
CustomException, \ | ||
InvalidItemException, \ | ||
BadRequestException, \ | ||
UnknownException) | ||
from api.core.types import Connection | ||
from app.core.types import Connection |
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,17 +1,27 @@ | ||
class CustomException(Exception): | ||
"""Basic exception for errors raised""" | ||
def __init__(self, message): | ||
self.message = message | ||
def __str__(self): | ||
return self.message | ||
pass | ||
|
||
class DBConnectionFailedException(CustomException): | ||
"""Unable to connect to repository""" | ||
pass | ||
|
||
class NotFoundException(CustomException): | ||
"""Unable to find item in repository""" | ||
pass | ||
|
||
class InvalidItemException(CustomException): | ||
"""Given an invalid item""" | ||
pass | ||
|
||
class BadRequestException(CustomException): | ||
"""Invalid item given""" | ||
pass | ||
|
||
class UnknownException(CustomException): | ||
"""Unknown""" | ||
"""Unknown""" | ||
pass |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.