Skip to content

Commit cfd50e9

Browse files
update cdm build scripts and add cmd 5.x unit test
1 parent e3c15a5 commit cfd50e9

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

test/cdm_tests/cdm_setup/get_cdm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rm -rf ../common-domain-model
2424
mkdir ../common-domain-model
2525
cd ../common-domain-model
2626
echo "***** pull CDM rosetta definitions"
27-
# CDM_VERSION="5.22.1"
27+
# CDM_VERSION="5.x.x"
2828
CDM_VERSION="master"
2929
git init
3030
git config core.sparseCheckout true
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# pylint: disable=unused-import,missing-function-docstring,invalid-name
2+
3+
# Works with CDM 5.x.x
4+
5+
from datetime import date
6+
from cdm.event.common.Trade import Trade
7+
from cdm.event.common.TradeIdentifier import TradeIdentifier
8+
from cdm.product.template.TradableProduct import TradableProduct
9+
from cdm.product.template.Product import Product
10+
from cdm.product.template.TradeLot import TradeLot
11+
from cdm.base.staticdata.party.Counterparty import Counterparty
12+
from cdm.product.common.settlement.PriceQuantity import PriceQuantity
13+
from cdm.base.staticdata.party.CounterpartyRoleEnum import CounterpartyRoleEnum
14+
from cdm.base.staticdata.party.Party import Party
15+
from cdm.base.staticdata.party.PartyIdentifier import PartyIdentifier
16+
from cdm.base.staticdata.identifier.AssignedIdentifier import AssignedIdentifier
17+
18+
def test_trade():
19+
product = Product()
20+
price_quantity = PriceQuantity()
21+
trade_lot = TradeLot(priceQuantity=[price_quantity])
22+
party_reference = Party(partyId=[PartyIdentifier(identifier="test")])
23+
counterparty = [Counterparty(role=CounterpartyRoleEnum.PARTY_1, partyReference=party_reference),
24+
Counterparty(role=CounterpartyRoleEnum.PARTY_2, partyReference=party_reference)]
25+
tradable_product = TradableProduct(product=product, tradeLot=[trade_lot], counterparty=counterparty)
26+
trade_identifier=[TradeIdentifier(assignedIdentifier=[AssignedIdentifier(identifier="Acme")])]
27+
28+
t = Trade(
29+
tradeDate=date(2023, 1, 1),
30+
tradableProduct=tradable_product,
31+
tradeIdentifier=trade_identifier
32+
)
33+
print(t.model_dump())
34+
print('Done!')
35+
36+
37+
if __name__ == '__main__':
38+
test_trade()
39+
40+
# EOF

test/cdm_tests/setup_cdm_test_env.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ MY_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2323
cd ${MY_PATH} || error
2424

2525
echo "***** setting up common environment"
26-
BUILDPATH="../../build"
27-
source $MY_PATH/$BUILDPATH/setup_python_env.sh
26+
PYTHONSETUPPATH="../python_setup"
27+
source $MY_PATH/$PYTHONSETUPPATH/setup_python_env.sh
2828

2929
echo "***** activating virtual environment"
3030
VENV_NAME=".pyenv"
31-
VENV_PATH=".."
32-
source $MY_PATH/$BUILDPATH/$VENV_PATH/$VENV_NAME/${PY_SCRIPTS}/activate || error
31+
VENV_PATH="../.."
32+
source $MY_PATH/$PYTHONSETUPPATH/$VENV_PATH/$VENV_NAME/${PY_SCRIPTS}/activate || error
3333

3434
# install cdm package
3535
PYTHONCDMDIR="../../target/python-cdm"

0 commit comments

Comments
 (0)