Skip to content
Snippets Groups Projects
Commit ce20e752 authored by dmitry.mashoshin's avatar dmitry.mashoshin
Browse files

Merge branch 'alesh/2317/multiawards-remove-winners-from-meta-for-cancelled-auctions' into 'master'

fix(multiAwards): exclude winners from public_meta for cancelled auctions

See merge request !566
parents b0651de9 e2b9e961
No related branches found
Tags v3.76.0
1 merge request!566fix(multiAwards): exclude winners from public_meta for cancelled auctions
Pipeline #73174 passed
......@@ -159,7 +159,19 @@ class MultiAwardsSimultaneousRound(mixins._CancellationMixin, states.Simultaneou
class Cancelled(states.Cancelled):
...
def onEnter(self):
"""
On cancelled state enter action.
"""
super().onEnter()
self._clean_winners()
def _clean_winners(self):
"""
Clean winners from public meta because auction is cancelled and there are no winners.
"""
if self._auction.public_meta:
self._auction.public_meta.pop('winners', None)
class Done(states.Done):
......
......@@ -260,3 +260,24 @@ class AuctionBuildTest(unittest.TestCase):
auth.AclContext(None, str(auction.bids[bid.id].ownerToken)),
validators=['ten_times_lg', ]
)
def test_cancel_auction_on_simultaneous_round(self):
auction = build_from_procedure_spec(self.PROCEDURE, 'multiAwards')
auction.set_state('simultaneous_round')
bid = list(auction.bids.values())[0]
bid_amount = 0.12
auction.place_bid(bid.id, bid_amount, auth.AclContext('test1', str(bid.ownerToken)))
bid = auction.bids[bid.id]
self.assertEqual(bid.amount, bid_amount * 100)
auction.cancel_auction()
with self.assertRaises(errors.ForbiddenStateError):
auction.place_bid(
bid.id, bid_amount,
auth.AclContext(None, str(auction.bids[bid.id].ownerToken)),
)
self.assertEqual(auction.current_state, 'cancelled')
self.assertIsNone(auction.endDate)
self.assertNotIn('winners', auction.public_meta.keys())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment