def test_deposit_invokes_private_deposit_method(self): obj = GrammarObject(label=None, keywords=['a']) mock_deposit = Mock() mock_expected = Mock() obj._deposit = mock_deposit obj._expected = mock_expected self.assertEqual(obj._ptr, 0) obj.deposit('a') self.assertTrue(mock_deposit.called) self.assertTrue(mock_expected.called) self.assertEqual(obj._ptr, 1)
def test_deposit_raises_exception_if_cannot_deposit_more(self): obj = GrammarObject(label=None, keywords=['a']) mock_deposit = Mock() mock_expected = Mock() obj._deposit = mock_deposit obj._expected = mock_expected self.assertEqual(obj._ptr, 0) obj.deposit('a') with self.assertRaises(Exception): obj.deposit('b') self.assertTrue(mock_deposit.call_count == 1) self.assertTrue(mock_expected.call_count == 1) self.assertEqual(obj._ptr, 1)