Skip to content

Commit

Permalink
Merge pull request #25 from alexanderthclark/auction-test
Browse files Browse the repository at this point in the history
Create test_auction.py
  • Loading branch information
alexanderthclark authored Jan 20, 2025
2 parents d939e5c + 1e93bc0 commit 449e527
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion freeride/double_auction.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def clear(self):
return price_range, n_trades

def __repr__(self):
return f"Price range: {self.price_range}\nQuantity: {self.q}"
return f"Price range: {self.price_range}\nQuantity: {self.q}"
29 changes: 29 additions & 0 deletions tests/test_auction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import unittest
from freeride.double_auction import UnitAgent, UnitDemand, UnitSupply, DoubleAuction

class TestDoubleAuction(unittest.TestCase):

def setUp(self):

#agent_a = UnitAgent(8, 1)
#agent_b = UnitAgent(9, 0)
#agent_c = UnitAgent(4, 1)
#agent_d = UnitAgent(5, 0)
agent_a = UnitSupply(8)
agent_b = UnitDemand(9)
agent_c = UnitSupply(4)
agent_d = UnitDemand(5)
self.agents = agent_a, agent_b, agent_c, agent_d

def test_double_auction(self):

auction = DoubleAuction(*self.agents)
price0, price1 = auction.p
q = auction.q

self.assertTrue(q == 1)
self.assertTrue(price0 == 5)
self.assertTrue(price1 == 8)

def tearDown(self):
pass

0 comments on commit 449e527

Please sign in to comment.