Skip to content

Commit

Permalink
Merge pull request #102 from masanorihirano/fix-coverage-20240407
Browse files Browse the repository at this point in the history
add coverage
  • Loading branch information
masanorihirano authored Apr 7, 2024
2 parents 659aea3 + ec6b2ed commit 68ba541
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/pams/test_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pams import Cancel
from pams import Market
from pams import Order
from pams.logs.base import ExpirationLog
from pams.logs.base import Logger
from pams.simulator import Simulator

Expand Down Expand Up @@ -749,3 +750,29 @@ def test_execution_order_pattern10(self) -> None:
assert market.remain_executable_orders()
logs = market._execution()
assert len(logs) == 2

def test_expiration_orrder(self) -> None:
logger = Logger()
market = self.base_class(
market_id=0,
prng=random.Random(42),
logger=logger,
simulator=Simulator(prng=random.Random(42)),
name="test",
)
market._update_time(1.0)
market._is_running = True
order = Order(
agent_id=0, market_id=0, is_buy=False, kind=MARKET_ORDER, volume=2, ttl=1
)
market._add_order(order)
order = Order(
agent_id=0, market_id=0, is_buy=True, kind=MARKET_ORDER, volume=1, ttl=1
)
market._add_order(order)
market._update_time(1.0)
market._update_time(1.0)
assert (
len([log for log in logger.pending_logs if isinstance(log, ExpirationLog)])
== 2
)

0 comments on commit 68ba541

Please sign in to comment.