From 1b7b6947bb6340bf568b9ca44391ec6d43ee0bae Mon Sep 17 00:00:00 2001 From: uvok Date: Mon, 14 Apr 2025 10:57:19 +0200 Subject: Ger remaining amount --- test_trade_queue.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test_trade_queue.py') 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() -- cgit v1.2.3