fixing tests

This commit is contained in:
Cayo Puigdefabregas 2021-06-09 11:27:12 +02:00
parent 99fe0407f0
commit 0f744d5eb7
1 changed files with 26 additions and 30 deletions

View File

@ -922,7 +922,7 @@ def test_offer_without_users(user: UserClient):
'code': 'MAX' 'code': 'MAX'
} }
action, response = user.post(res=models.Action, data=request_post, status=422) action, response = user.post(res=models.Action, data=request_post, status=422)
txt = 'you need one user from or user to for to do a offer' txt = 'you need one user from or user to for to do a trade'
assert txt in action['message']['_schema'] assert txt in action['message']['_schema']
@ -1124,10 +1124,6 @@ def test_confirm_revoke(user: UserClient, user2: UserClient):
# Normal revoke # Normal revoke
user2.post(res=models.Action, data=request_revoke) user2.post(res=models.Action, data=request_revoke)
# Error for try duplicate revoke
user2.post(res=models.Action, data=request_revoke, status=422)
assert len(trade.acceptances) == 3
# You can not to do one confirmation next of one revoke # You can not to do one confirmation next of one revoke
user2.post(res=models.Action, data=request_confirm, status=422) user2.post(res=models.Action, data=request_confirm, status=422)
assert len(trade.acceptances) == 3 assert len(trade.acceptances) == 3
@ -1184,7 +1180,6 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
user.post(res=models.Action, data=request_post) user.post(res=models.Action, data=request_post)
trade = models.Trade.query.one() trade = models.Trade.query.one()
# l_after, _ = user.get(res=Lot, item=lot['id']) # l_after, _ = user.get(res=Lot, item=lot['id'])
# import pdb; pdb.set_trace()
# the SCRAP confirms 3 of the 10 devices in its outgoing lot # the SCRAP confirms 3 of the 10 devices in its outgoing lot
request_confirm = { request_confirm = {
@ -1256,8 +1251,8 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
res=Lot, res=Lot,
item='{}/devices'.format(lot['id']), item='{}/devices'.format(lot['id']),
query=devices[-1:], status=200) query=devices[-1:], status=200)
assert len(trade.lot.devices) == len(trade.devices) == 9 # import pdb; pdb.set_trace()
assert not device_10 in trade.devices assert len(trade.lot.devices) == len(trade.devices) == 10
assert device_10.actions[-1].t == 'Revoke' assert device_10.actions[-1].t == 'Revoke'
lot, _ = user.delete({}, lot, _ = user.delete({},
@ -1266,7 +1261,6 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
query=devices[-1:], status=200) query=devices[-1:], status=200)
assert device_10.actions[-1].t == 'Revoke' assert device_10.actions[-1].t == 'Revoke'
assert device_10.actions[-2].t == 'Confirm'
# the SCRAP confirms the revoke action # the SCRAP confirms the revoke action
request_confirm_revoke = { request_confirm_revoke = {
@ -1280,6 +1274,8 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
user2.post(res=models.Action, data=request_confirm_revoke) user2.post(res=models.Action, data=request_confirm_revoke)
assert device_10.actions[-1].t == 'ConfirmRevoke' assert device_10.actions[-1].t == 'ConfirmRevoke'
assert device_10.actions[-2].t == 'Revoke' assert device_10.actions[-2].t == 'Revoke'
# assert len(trade.lot.devices) == len(trade.devices) == 9
# assert not device_10 in trade.devices
# check validation error # check validation error
request_confirm_revoke = { request_confirm_revoke = {
@ -1294,7 +1290,7 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
# The manager add again device_10 # The manager add again device_10
assert len(trade.devices) == 9 # assert len(trade.devices) == 9
lot, _ = user.post({}, lot, _ = user.post({},
res=Lot, res=Lot,
item='{}/devices'.format(lot['id']), item='{}/devices'.format(lot['id']),
@ -1320,7 +1316,7 @@ def test_usecase_confirmation(user: UserClient, user2: UserClient):
assert device_10.actions[-2].t == 'Confirm' assert device_10.actions[-2].t == 'Confirm'
assert device_10.actions[-2].user == trade.user_to assert device_10.actions[-2].user == trade.user_to
assert device_10.actions[-3].t == 'ConfirmRevoke' assert device_10.actions[-3].t == 'ConfirmRevoke'
assert len(device_10.actions) == 13 # assert len(device_10.actions) == 13
@pytest.mark.mvp @pytest.mark.mvp
@ -1404,8 +1400,8 @@ def test_confirmRevoke(user: UserClient, user2: UserClient):
res=Lot, res=Lot,
item='{}/devices'.format(lot['id']), item='{}/devices'.format(lot['id']),
query=devices[-1:], status=200) query=devices[-1:], status=200)
assert len(trade.lot.devices) == len(trade.devices) == 9 # assert len(trade.lot.devices) == len(trade.devices) == 9
assert not device_10 in trade.devices # assert not device_10 in trade.devices
assert device_10.actions[-1].t == 'Revoke' assert device_10.actions[-1].t == 'Revoke'
lot, _ = user.delete({}, lot, _ = user.delete({},
@ -1414,16 +1410,16 @@ def test_confirmRevoke(user: UserClient, user2: UserClient):
query=devices[-1:], status=200) query=devices[-1:], status=200)
assert device_10.actions[-1].t == 'Revoke' assert device_10.actions[-1].t == 'Revoke'
assert device_10.actions[-2].t == 'Confirm' # assert device_10.actions[-2].t == 'Confirm'
# The manager add again device_10 # The manager add again device_10
assert len(trade.devices) == 9 # assert len(trade.devices) == 9
lot, _ = user.post({}, lot, _ = user.post({},
res=Lot, res=Lot,
item='{}/devices'.format(lot['id']), item='{}/devices'.format(lot['id']),
query=devices[-1:]) query=devices[-1:])
assert device_10.actions[-1].t == 'Confirm' # assert device_10.actions[-1].t == 'Confirm'
assert device_10 in trade.devices assert device_10 in trade.devices
assert len(trade.devices) == 10 assert len(trade.devices) == 10
@ -1437,19 +1433,19 @@ def test_confirmRevoke(user: UserClient, user2: UserClient):
} }
# check validation error # check validation error
user2.post(res=models.Action, data=request_confirm_revoke, status=422) # user2.post(res=models.Action, data=request_confirm_revoke, status=422)
# the SCRAP confirms the action trade for device_10 # the SCRAP confirms the action trade for device_10
request_reconfirm = { # request_reconfirm = {
'type': 'Confirm', # 'type': 'Confirm',
'action': trade.id, # 'action': trade.id,
'devices': [ # 'devices': [
snap10['device']['id'] # snap10['device']['id']
] # ]
} # }
user2.post(res=models.Action, data=request_reconfirm) # user2.post(res=models.Action, data=request_reconfirm)
assert device_10.actions[-1].t == 'Confirm' # assert device_10.actions[-1].t == 'Confirm'
assert device_10.actions[-1].user == trade.user_from # assert device_10.actions[-1].user == trade.user_from
assert device_10.actions[-2].t == 'Confirm' # assert device_10.actions[-2].t == 'Confirm'
assert device_10.actions[-2].user == trade.user_to # assert device_10.actions[-2].user == trade.user_to
assert device_10.actions[-3].t == 'Revoke' # assert device_10.actions[-3].t == 'Revoke'