diff options
author | uvok | 2025-04-14 10:57:19 +0200 |
---|---|---|
committer | uvok | 2025-04-14 10:57:19 +0200 |
commit | 1b7b6947bb6340bf568b9ca44391ec6d43ee0bae (patch) | |
tree | 2333a1537033569b329f8c4e7ffa185280fc403e /test_trade_queue.py | |
parent | ceedc4c3c19da7f01e1c315cb5c41bf4a4c59672 (diff) |
Ger remaining amount
Diffstat (limited to 'test_trade_queue.py')
-rw-r--r-- | test_trade_queue.py | 35 |
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() |