summaryrefslogtreecommitdiff
path: root/test_trade_queue.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_trade_queue.py')
-rw-r--r--test_trade_queue.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/test_trade_queue.py b/test_trade_queue.py
index 958b830..3a72e4a 100644
--- a/test_trade_queue.py
+++ b/test_trade_queue.py
@@ -63,5 +63,40 @@ class TestFIFOQueue(unittest.TestCase):
with self.assertRaises(ValueError):
self.queue.remove(-5.0) # This should raise an exception
+ def test_get_remaining_amount_initial(self):
+ """
+ Test the remaining amount in the queue after adding trades.
+ """
+ self.assertEqual(self.queue.get_remaining_amount(), 60.0) # Total of all amounts: 10 + 20 + 30
+
+ def test_get_remaining_amount_after_removal(self):
+ """
+ Test the remaining amount after removing some assets.
+ """
+ self.queue.remove(15.0) # Remove 15 assets
+ self.assertEqual(self.queue.get_remaining_amount(), 45.0) # Remaining: 60 - 15
+
+ def test_get_remaining_amount_empty_queue(self):
+ """
+ Test the remaining amount in an empty queue.
+ """
+ empty_queue = FIFOQueue() # New empty queue
+ self.assertEqual(empty_queue.get_remaining_amount(), 0.0) # No trades in queue
+
+ def test_get_remaining_amount_partial_removal(self):
+ """
+ Test the remaining amount after partially consuming a trade.
+ """
+ self.queue.remove(5.0) # Remove 5 assets, leaving 5 in the first trade
+ self.assertEqual(self.queue.get_remaining_amount(), 55.0) # Remaining: 60 - 5
+
+ def test_get_remaining_amount_full_removal(self):
+ """
+ Test the remaining amount after removing all trades.
+ """
+ self.queue.remove(60.0) # Remove all assets
+ self.assertEqual(self.queue.get_remaining_amount(), 0.0) # Remaining: 0
+
+
if __name__ == "__main__":
unittest.main()