import unittest

from ledger import Ledger


class HoldoutLedgerTests(unittest.TestCase):
    def test_rejected_id_remains_globally_available(self):
        ledger = Ledger()
        with self.assertRaises(ValueError):
            ledger.apply("shared", "a", -1)
        self.assertEqual(ledger.apply("shared", "b", 3), 3)

    def test_successful_id_is_global_across_accounts(self):
        ledger = Ledger()
        ledger.apply("shared", "a", 3)
        self.assertEqual(ledger.apply("shared", "b", 9), 0)
