Skip to content

Universal-Commerce-Protocol/conformance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UCP SDK Integration Tests

This directory contains integration tests that run against a running UCP Merchant Server instance. These tests are language-agnostic regarding the server implementation (Python, Node.js, etc.) and verify adherence to the UCP specification.

Prerequisites

The tests assume a UCP Merchant Server is running and accessible via HTTP. The server must be started with databases initialized using data from test_data/flower_shop directory. Instructions to start the servers follow.

NOTE: These instructions assume the commands are executed from the directory containing this README.

Updating dependencies

uv sync

uv sync --directory ../samples/rest/python/server/

uv sync --directory ../sdk/python/

Initializing the database

DATABASE_PATH=/tmp/ucp_test

rm -rf ${DATABASE_PATH}
mkdir ${DATABASE_PATH}

uv run --directory ../samples/rest/python/server import_csv.py \
    --products_db_path=${DATABASE_PATH}/products.db \
    --transactions_db_path=${DATABASE_PATH}/transactions.db \
    --data_dir=../../../../conformance/test_data/flower_shop

Starting the server:

SIMULATION_SECRET=super-secret-sim-key
MERCHANT_SERVER_PORT=8182

uv run --directory ../samples/rest/python/server server.py \
    --products_db_path=${DATABASE_PATH}/products.db \
    --transactions_db_path=${DATABASE_PATH}/transactions.db \
    --port=${MERCHANT_SERVER_PORT} \
    --simulation_secret=${SIMULATION_SECRET} &
MERCHANT_SERVER_PID=$!

Running the Tests

for test_file in *_test.py; do
uv run ${test_file} \
    --server_url=http://localhost:${MERCHANT_SERVER_PORT} \
    --simulation_secret=${SIMULATION_SECRET} \
    --conformance_input=test_data/flower_shop/conformance_input.json
done

Cleaning Up

Terminate the server using:

kill ${MERCHANT_SERVER_PID}

Examining the database state

After running tests, one can examine the database state using the dump_transactions and dump_log tools:

uv run --directory ../samples/rest/python/server dump_transactions.py \
    --transactions_db_path=${DATABASE_PATH}/transactions.db
uv run --directory ../samples/rest/python/server dump_log.py \
    --transactions_db_path=${DATABASE_PATH}/transactions.db

About

Conformance Tests for UCP

Resources

License

Security policy

Stars

Watchers

Forks

Contributors 6

Languages