InstaFuel_Chatbot_public/scripts/test_product_formatting.py
2026-04-21 11:57:37 +05:30

42 lines
1 KiB
Python

import sys
import os
# Add src to python path
sys.path.append(os.path.join(os.path.dirname(__file__), "../src"))
from utils import stringify_dict
def test_product_formatting():
product_with_url = {
"name": "Test Product",
"price": "100",
"product_url": "https://example.com/product"
}
product_with_link = {
"name": "Test Product 2",
"price": "200",
"link": "https://example.com/product2"
}
print("--- Test 1: product_url ---")
output1 = stringify_dict(product_with_url)
print(output1)
if "https://example.com/product" in output1:
print("PASS: URL found in output")
else:
print("FAIL: URL not found in output")
print("\n--- Test 2: link ---")
output2 = stringify_dict(product_with_link)
print(output2)
if "https://example.com/product2" in output2:
print("PASS: Link found in output")
else:
print("FAIL: Link not found in output")
if __name__ == "__main__":
test_product_formatting()