rebuild trading function

This commit is contained in:
Cayo Puigdefabregas 2021-11-11 22:08:28 +01:00
parent cef22f01ce
commit 872a0be866
5 changed files with 210 additions and 109 deletions

View File

@ -147,10 +147,7 @@ class Metrics(MetricsMix):
if the action is one trade action, is possible than have a list of confirmations.
Get the doble confirm for to know if this trade is confirmed or not.
"""
# import pdb; pdb.set_trace()
if self.device.trading(self.act.lot) == 'TradeConfirmed':
return True
return False
return self.device.trading(self.act.lot)
def get_trade(self):
"""

View File

@ -330,6 +330,81 @@ class Device(Thing):
5: 'NeedConfirmRevoke',
6: 'RevokeConfirmed'}
trade = lot.trade
user_from = trade.user_from
user_to = trade.user_to
status = 0
last_user = None
if not hasattr(trade, 'acceptances'):
return Status[status]
for ac in self.actions:
if ac.t not in ['Confirm', 'Revoke']:
continue
if ac.user not in [user_from, user_to]:
continue
if ac.t == 'Confirm' and ac.action == trade:
if status in [0, 6]:
status = 1
last_user = ac.user
if ac.user == user_from and user_to == g.user:
status = 2
if ac.user == user_to and user_from == g.user:
status = 2
continue
if status in [1, 2]:
if last_user != ac.user:
status = 3
last_user = ac.user
continue
if status in [4, 5]:
status = 3
last_user = ac.user
continue
if ac.t == 'Revoke' and ac.action == trade:
if status == 3:
status = 4
last_user = ac.user
if ac.user == user_from and user_to == g.user:
status = 5
if ac.user == user_to and user_from == g.user:
status = 5
continue
if status in [4, 5]:
if last_user != ac.user:
status = 6
last_user = ac.user
continue
if status in [1, 2]:
status = 6
last_user = ac.user
continue
return Status[status]
def trading_for_web2(self, lot):
"""The trading state, or None if no Trade action has
ever been performed to this device. This extract the posibilities for to do.
This method is performed for show in the web."""
if not hasattr(lot, 'trade'):
return
Status = {0: 'Trade',
1: 'Confirm',
2: 'NeedConfirmation',
3: 'TradeConfirmed',
4: 'Revoke',
5: 'NeedConfirmRevoke',
6: 'RevokeConfirmed'}
trade = lot.trade
user_from = trade.user_from
user_to = trade.user_to
@ -353,7 +428,6 @@ class Device(Thing):
if ac.t == 'Confirm' and ac.action == trade:
if ac.user == user_from:
user_from_confirm = True
# import pdb; pdb.set_trace()
last_action['confirm'] = time.mktime(ac.created.timetuple())
user_from_revoke, user_to_revoke = False, False
elif ac.user == user_to:
@ -398,24 +472,22 @@ class Device(Thing):
def trading(self, lot):
"""The trading state, or None if no Trade action has
ever been performed to this device. This extract the posibilities for to do"""
ever been performed to this device. This extract the posibilities for to do.
This method is performed for show in the web."""
if not hasattr(lot, 'trade'):
return
Status = {0: 'Trade',
1: 'Confirm',
2: 'TradeConfirmed',
3: 'Revoke',
4: 'RevokeConfirmed'}
2: 'NeedConfirmation',
3: 'TradeConfirmed',
5: 'NeedConfirmRevoke',
6: 'RevokeConfirmed'}
trade = lot.trade
user_from = trade.user_from
user_to = trade.user_to
user_from_confirm = False
user_to_confirm = False
user_from_revoke = False
user_to_revoke = False
status = 0
last_user = None
if not hasattr(trade, 'acceptances'):
return Status[status]
@ -428,29 +500,38 @@ class Device(Thing):
continue
if ac.t == 'Confirm' and ac.action == trade:
if ac.user == user_from:
user_from_confirm = True
elif ac.user == user_to:
user_to_confirm = True
if status in [0, 6]:
status = 2
last_user = ac.user
continue
if status == 2:
if last_user != ac.user:
status = 3
last_user = ac.user
continue
if status == 5:
status = 3
last_user = ac.user
continue
if ac.t == 'Revoke' and ac.action == trade:
if ac.user == user_from:
user_from_revoke = True
elif ac.user == user_to:
user_to_revoke = True
if status == 3:
status = 5
last_user = ac.user
continue
confirms = [user_from_confirm, user_to_confirm]
revokes = [user_from_revoke, user_to_revoke]
if status == 5:
if last_user != ac.user:
status = 6
last_user = ac.user
continue
if any(confirms):
status = 1
if all(confirms):
status = 2
if any(revokes):
status = 3
if all(revokes):
status = 4
if status == 2:
status = 6
last_user = ac.user
continue
return Status[status]

View File

@ -269,7 +269,6 @@ def delete_from_trade(lot: Lot, devices: List):
drop_of_lot = []
without_confirms = []
# import pdb; pdb.set_trace()
for dev in devices:
if dev.trading_for_web(lot) in ['NeedConfirmation', 'Confirm', 'NeedConfirmRevoke']:
drop_of_lot.append(dev)

View File

@ -328,7 +328,7 @@ def test_outgoinlot_status_actions(action_model: models.Action, user: UserClient
assert device['actions'][-1]['id'] == action['id']
assert action['author']['id'] == user.user['id']
assert action['rol_user']['id'] == user.user['id']
assert action['rol_user']['id'] == user2.user['id']
@pytest.mark.mvp
@ -1709,7 +1709,6 @@ def test_confirmRevoke(user: UserClient, user2: UserClient):
assert len(trade.devices) == 10
# the SCRAP confirms the revoke action
import pdb; pdb.set_trace()
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device_10.actions[-2].id,
@ -1770,31 +1769,23 @@ def test_trade_case1(user: UserClient, user2: UserClient):
user.post(res=models.Action, data=request_post)
trade = models.Trade.query.one()
lot, _ = user.post({},
res=Lot,
item='{}/devices'.format(lot['id']),
query=devices[-1:])
lot = trade.lot
device = trade.devices[0]
device1, device2 = trade.devices
assert device.actions[-2].t == 'Trade'
assert device.actions[-1].t == 'Confirm'
assert device.actions[-1].user == trade.user_to
assert device1.actions[-2].t == 'Trade'
assert device1.actions[-1].t == 'Confirm'
assert device1.actions[-1].user == trade.user_to
assert device2.actions[-2].t == 'Trade'
assert device2.actions[-1].t == 'Confirm'
assert device2.actions[-1].user == trade.user_to
user.delete({},
res=Lot,
item='{}/devices'.format(lot.id),
query=devices[:-1], status=200)
lot, _ = user.delete({},
res=Lot,
item='{}/devices'.format(lot['id']),
query=devices, status=200)
assert device1.actions[-2].t == 'Revoke'
assert device1.actions[-1].t == 'ConfirmRevoke'
assert device1.actions[-1].user == trade.user_to
assert device2.actions[-2].t == 'Revoke'
assert device2.actions[-1].t == 'ConfirmRevoke'
assert device2.actions[-1].user == trade.user_to
assert device not in trade.lot.devices
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
assert device.actions[-2].t == 'Confirm'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_to
@pytest.mark.mvp
@ -1837,6 +1828,7 @@ def test_trade_case2(user: UserClient, user2: UserClient):
device1, device2 = trade.devices
# import pdb; pdb.set_trace()
assert device1.actions[-2].t == 'Trade'
assert device1.actions[-1].t == 'Confirm'
assert device1.actions[-1].user == trade.user_to
@ -1853,12 +1845,13 @@ def test_trade_case2(user: UserClient, user2: UserClient):
# Normal revoke
user.post(res=models.Action, data=request_revoke)
assert device1.actions[-2].t == 'Revoke'
assert device1.actions[-1].t == 'ConfirmRevoke'
assert device1.actions[-2].t == 'Confirm'
assert device1.actions[-1].t == 'Revoke'
assert device1.actions[-1].user == trade.user_to
assert device2.actions[-2].t == 'Revoke'
assert device2.actions[-1].t == 'ConfirmRevoke'
assert device2.actions[-2].t == 'Confirm'
assert device2.actions[-1].t == 'Revoke'
assert device2.actions[-1].user == trade.user_to
assert device1.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -1866,7 +1859,6 @@ def test_trade_case2(user: UserClient, user2: UserClient):
def test_trade_case3(user: UserClient, user2: UserClient):
# the pRp (manatest_usecase_confirmationger) creates a temporary lot
lot, _ = user.post({'name': 'MyLot'}, res=Lot)
# The manager add 7 device into the lot
snap1, _ = user.post(file('basic.snapshot'), res=models.Snapshot)
snap2, _ = user2.post(file('acer.happy.battery.snapshot'), res=models.Snapshot)
@ -1913,9 +1905,10 @@ def test_trade_case3(user: UserClient, user2: UserClient):
item='{}/devices'.format(lot['id']),
query=devices[-1:], status=200)
assert device2.actions[-2].t == 'Revoke'
assert device2.actions[-1].t == 'ConfirmRevoke'
assert device2.actions[-2].t == 'Confirm'
assert device2.actions[-1].t == 'Revoke'
assert device2.actions[-1].user == trade.user_from
assert device2.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -1977,9 +1970,10 @@ def test_trade_case4(user: UserClient, user2: UserClient):
assert device1.actions[-2].t == 'Trade'
assert device1.actions[-1].t == 'Confirm'
assert device1.actions[-1].user == trade.user_to
assert device2.actions[-2].t == 'Revoke'
assert device2.actions[-1].t == 'ConfirmRevoke'
assert device2.actions[-2].t == 'Confirm'
assert device2.actions[-1].t == 'Revoke'
assert device2.actions[-1].user == trade.user_from
assert device2.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -2034,8 +2028,8 @@ def test_trade_case5(user: UserClient, user2: UserClient):
assert device2.actions[-1].user == trade.user_from
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device2.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device2.id],
}
@ -2043,8 +2037,9 @@ def test_trade_case5(user: UserClient, user2: UserClient):
user.post(res=models.Action, data=request_confirm_revoke)
assert device2.actions[-2].t == 'Revoke'
assert device2.actions[-1].t == 'ConfirmRevoke'
assert device2.actions[-1].t == 'Revoke'
assert device2.actions[-1].user == trade.user_to
assert device2.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -2104,8 +2099,8 @@ def test_trade_case6(user: UserClient, user2: UserClient):
assert device2.actions[-1].user == trade.user_to
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device2.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device2.id],
}
@ -2113,8 +2108,9 @@ def test_trade_case6(user: UserClient, user2: UserClient):
user2.post(res=models.Action, data=request_confirm_revoke)
assert device2.actions[-2].t == 'Revoke'
assert device2.actions[-1].t == 'ConfirmRevoke'
assert device2.actions[-1].t == 'Revoke'
assert device2.actions[-1].user == trade.user_from
assert device2.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -2156,6 +2152,7 @@ def test_trade_case7(user: UserClient, user2: UserClient):
# Normal revoke
user2.post(res=models.Action, data=request_confirm)
assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
lot, _ = user.delete({},
res=Lot,
@ -2163,14 +2160,14 @@ def test_trade_case7(user: UserClient, user2: UserClient):
query=devices, status=200)
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
user2.post(res=models.Action, data=request_confirm_revoke)
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_from
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_to
@ -2180,6 +2177,7 @@ def test_trade_case7(user: UserClient, user2: UserClient):
assert device.actions[-4].user == trade.user_to
assert device.actions[-5].t == 'Trade'
assert device.actions[-5].author == trade.user_to
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -2221,6 +2219,7 @@ def test_trade_case8(user: UserClient, user2: UserClient):
# Normal revoke
user2.post(res=models.Action, data=request_confirm)
assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
request_revoke = {
'type': 'Revoke',
@ -2232,14 +2231,14 @@ def test_trade_case8(user: UserClient, user2: UserClient):
user.post(res=models.Action, data=request_revoke)
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
user2.post(res=models.Action, data=request_confirm_revoke)
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_from
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_to
@ -2249,6 +2248,7 @@ def test_trade_case8(user: UserClient, user2: UserClient):
assert device.actions[-4].user == trade.user_to
assert device.actions[-5].t == 'Trade'
assert device.actions[-5].author == trade.user_to
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -2301,6 +2301,7 @@ def test_trade_case9(user: UserClient, user2: UserClient):
# Normal revoke
user.post(res=models.Action, data=request_confirm)
assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
assert device.owner == trade.user_to
@ -2310,8 +2311,8 @@ def test_trade_case9(user: UserClient, user2: UserClient):
query=devices[-1:], status=200)
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
@ -2319,7 +2320,7 @@ def test_trade_case9(user: UserClient, user2: UserClient):
assert device.owner == trade.user_from
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_to
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_from
@ -2329,6 +2330,7 @@ def test_trade_case9(user: UserClient, user2: UserClient):
assert device.actions[-4].user == trade.user_from
assert device.actions[-5].t == 'Trade'
assert device.actions[-5].author == trade.user_to
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -2372,6 +2374,7 @@ def test_trade_case10(user: UserClient, user2: UserClient):
device1, device = trade.devices
assert device.owner == trade.user_from
# assert device.trading_for_web(trade.lot) == 'Confirm'
request_confirm = {
'type': 'Confirm',
@ -2381,6 +2384,7 @@ def test_trade_case10(user: UserClient, user2: UserClient):
# Normal confirm
user.post(res=models.Action, data=request_confirm)
# assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
assert device.owner == trade.user_to
@ -2392,18 +2396,18 @@ def test_trade_case10(user: UserClient, user2: UserClient):
# Normal revoke
user2.post(res=models.Action, data=request_revoke)
assert device.trading_for_web(trade.lot) == 'Revoke'
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
user.post(res=models.Action, data=request_confirm_revoke)
assert device.owner == trade.user_from
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_to
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_from
@ -2413,6 +2417,7 @@ def test_trade_case10(user: UserClient, user2: UserClient):
assert device.actions[-4].user == trade.user_from
assert device.actions[-5].t == 'Trade'
assert device.actions[-5].author == trade.user_to
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
@pytest.mark.mvp
@ -2449,6 +2454,7 @@ def test_trade_case11(user: UserClient, user2: UserClient):
trade = models.Trade.query.one()
device1, device = trade.devices
assert device.trading_for_web(trade.lot) == 'Confirm'
request_confirm = {
'type': 'Confirm',
@ -2457,21 +2463,24 @@ def test_trade_case11(user: UserClient, user2: UserClient):
}
user2.post(res=models.Action, data=request_confirm)
assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
lot, _ = user2.delete({},
res=Lot,
item='{}/devices'.format(lot['id']),
query=devices[-1:], status=200)
assert device.trading_for_web(trade.lot) == 'Revoke'
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
user.post(res=models.Action, data=request_confirm_revoke)
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_to
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_from
@ -2517,6 +2526,7 @@ def test_trade_case12(user: UserClient, user2: UserClient):
trade = models.Trade.query.one()
device1, device = trade.devices
assert device.trading_for_web(trade.lot) == 'Confirm'
# Normal confirm
request_confirm = {
@ -2526,6 +2536,7 @@ def test_trade_case12(user: UserClient, user2: UserClient):
}
user2.post(res=models.Action, data=request_confirm)
assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
request_revoke = {
'type': 'Revoke',
@ -2535,16 +2546,18 @@ def test_trade_case12(user: UserClient, user2: UserClient):
# Normal revoke
user2.post(res=models.Action, data=request_revoke)
assert device.trading_for_web(trade.lot) == 'Revoke'
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
user.post(res=models.Action, data=request_confirm_revoke)
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_to
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_from
@ -2595,6 +2608,8 @@ def test_trade_case13(user: UserClient, user2: UserClient):
query=devices[-1:])
device1, device = trade.devices
assert device1.trading_for_web(trade.lot) == 'NeedConfirmation'
assert device.trading_for_web(trade.lot) == 'Confirm'
request_confirm = {
'type': 'Confirm',
@ -2603,21 +2618,26 @@ def test_trade_case13(user: UserClient, user2: UserClient):
}
user.post(res=models.Action, data=request_confirm)
assert device1.trading_for_web(trade.lot) == 'Confirm'
assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
lot, _ = user.delete({},
res=Lot,
item='{}/devices'.format(lot['id']),
query=devices[-1:], status=200)
assert device1.trading_for_web(trade.lot) == 'Confirm'
assert device.trading_for_web(trade.lot) == 'Revoke'
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
user2.post(res=models.Action, data=request_confirm_revoke)
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_from
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_to
@ -2668,6 +2688,8 @@ def test_trade_case14(user: UserClient, user2: UserClient):
query=devices[-1:])
device1, device = trade.devices
assert device1.trading_for_web(trade.lot) == 'NeedConfirmation'
assert device.trading_for_web(trade.lot) == 'Confirm'
# Normal confirm
request_confirm = {
@ -2677,6 +2699,7 @@ def test_trade_case14(user: UserClient, user2: UserClient):
}
user.post(res=models.Action, data=request_confirm)
assert device.trading_for_web(trade.lot) == 'TradeConfirmed'
request_revoke = {
'type': 'Revoke',
@ -2686,16 +2709,18 @@ def test_trade_case14(user: UserClient, user2: UserClient):
# Normal revoke
user.post(res=models.Action, data=request_revoke)
assert device.trading_for_web(trade.lot) == 'Revoke'
request_confirm_revoke = {
'type': 'ConfirmRevoke',
'action': device.actions[-1].id,
'type': 'Revoke',
'action': trade.id,
'devices': [device.id],
}
user2.post(res=models.Action, data=request_confirm_revoke)
assert device.trading_for_web(trade.lot) == 'RevokeConfirmed'
assert device.actions[-1].t == 'ConfirmRevoke'
assert device.actions[-1].t == 'Revoke'
assert device.actions[-1].user == trade.user_from
assert device.actions[-2].t == 'Revoke'
assert device.actions[-2].user == trade.user_to

View File

@ -181,14 +181,13 @@ def test_complet_metrics_with_trade(user: UserClient, user2: UserClient):
query=[('filter', {'type': ['Computer']})])
body1_lenovo = 'O48N2;desktop-lenovo-9644w8n-0169622-00:1a:6b:5e:7f:10;;Trade;foo@foo.com;'
body1_lenovo += 'foo2@foo.com;Supplier;False;Use;;'
body1_lenovo += 'foo2@foo.com;Supplier;NeedConfirmation;Use;;'
body2_lenovo = ';;0;0;Trade;0;0\n'
body1_acer = 'J2MA2;laptop-acer-aohappy-lusea0d010038879a01601-00:26:c7:8e:cb:8c;;Trade;'
body1_acer += 'foo@foo.com;foo2@foo.com;Supplier;False;;;;;0;'
body1_acer += 'foo@foo.com;foo2@foo.com;Supplier;NeedConfirmation;;;;;0;'
body2_acer = ';;0;0;Trade;0;4692.0\n'
# import pdb; pdb.set_trace()
assert body1_lenovo in csv_str
assert body2_lenovo in csv_str
assert body1_acer in csv_str
@ -203,7 +202,7 @@ def test_complet_metrics_with_trade(user: UserClient, user2: UserClient):
query=[('filter', {'type': ['Computer']})])
body1_lenovo = 'O48N2;desktop-lenovo-9644w8n-0169622-00:1a:6b:5e:7f:10;;Trade;foo@foo.com;'
body1_lenovo += 'foo2@foo.com;Supplier;False;Use;Use;'
body1_lenovo += 'foo2@foo.com;Supplier;NeedConfirmation;Use;Use;'
body2_lenovo = ';;0;0;Trade;0;0\n'
body2_acer = ';;0;0;Trade;0;4692.0\n'
@ -353,8 +352,8 @@ def test_bug_trade_confirmed(user: UserClient, user2: UserClient):
accept='text/csv',
query=[('filter', {'type': ['Computer']})])
body_not_confirmed = "Trade;foo2@foo.com;foo@foo.com;Receiver;False;"
body_confirmed = "Trade;foo2@foo.com;foo@foo.com;Receiver;True;"
body_not_confirmed = "Trade;foo2@foo.com;foo@foo.com;Receiver;NeedConfirmation;"
body_confirmed = "Trade;foo2@foo.com;foo@foo.com;Receiver;TradeConfirmed;"
assert body_not_confirmed in csv_not_confirmed
assert body_confirmed in csv_confirmed