odoo_dev 开发培训作业:图书管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.3KB

  1. from odoo.tests.common import TransactionCase
  2. from odoo import exceptions
  3. class TestWizard(TransactionCase):
  4. def setUp(self, *args, **kwargs):
  5. super().setUp(*args, **kwargs)
  6. # Setup test data
  7. admin_user = self.env.ref('base.user_admin')
  8. self.Checkout = self.env['library.checkout'].with_user(admin_user)
  9. self.Wizard = self.env['library.checkout.massmessage'].with_user(admin_user)
  10. a_member = self.env['library.member'].create({'name': 'John'})
  11. self.checkout0 = self.Checkout.create({
  12. 'member_id': a_member.id})
  13. def test_button_send(self):
  14. """Send button should create messages on Checkouts"""
  15. # Add test code
  16. msgs_before = len(self.checkout0.message_ids)
  17. Wizard0 = self.Wizard.with_context(active_ids=self.checkout0.ids)
  18. wizard0 = Wizard0.create({'message_body': 'Hello'})
  19. wizard0.button_send()
  20. msgs_after = len(self.checkout0.message_ids)
  21. self.assertEqual(
  22. msgs_after,
  23. msgs_before+1,
  24. 'Expected on additional message in the Checkout.')
  25. def test_button_send_empty_body(self):
  26. "Send button errors on empty body message"
  27. wizard0 = self.Wizard.create({})
  28. with self.assertRaises(exceptions.UserError) as e:
  29. wizard0.button_send()
上海开阖软件有限公司 沪ICP备12045867号-1