Skip to content

Commit

Permalink
refactor VALID_CROPS into comma separated list
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaszimmermann committed Jan 10, 2025
1 parent 74ec727 commit 9b1065d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Settings(BaseSettings):
APP_DEBUG: bool = False

# list of valid crops
VALID_CROPS: list = ["coffee", "maize"]
VALID_CROPS: str = "coffee,maize,beans,potatoes"

# model fields settings
MODEL_ID_ATTRIBUTE: str = "id"
Expand Down
8 changes: 4 additions & 4 deletions app/server/model/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def config_must_exist(cls, v:str) -> str:
def crop_must_be_valid(cls, v: str) -> str:
crop = v.strip().lower()

if crop not in settings.VALID_CROPS:
raise_with_log(ValueError, f"crop {crop} invalid, valid crops are {VALID_CROPS}")
if crop not in settings.VALID_CROPS.split(","):
raise_with_log(ValueError, f"crop {crop} invalid, valid crops are {settings.VALID_CROPS}")

return crop

Expand Down Expand Up @@ -163,8 +163,8 @@ def config_must_exist(cls, v:str) -> str:
def crop_must_be_valid(cls, v: str) -> str:
crop = v.strip().lower()

if crop not in settings.VALID_CROPS:
raise_with_log(ValueError, f"crop {crop} invalid, valid crops are {VALID_CROPS}")
if crop not in settings.VALID_CROPS.split(","):
raise_with_log(ValueError, f"crop {crop} invalid, valid crops are {settings.VALID_CROPS}")

return crop

Expand Down
2 changes: 1 addition & 1 deletion script/MockSetup.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ contract MocksSetupScript is Script {
console.log("Token deployed", address(token));
console.log("Product deployed", address(product));
}
}
}

0 comments on commit 9b1065d

Please sign in to comment.