|
- from odoo.tests.common import TransactionCase
- from odoo.tests.common import HttpCase
- from odoo.exceptions import UserError
-
-
-
-
- class TestBook(TransactionCase):
- def setUp(self, *args, **kwargs):
- result = super().setUp(*args, **kwargs)
- user_admin = self.env.ref('base.user_admin')
- self.env = self.env(user=user_admin)
- self.Book = self.env['library.book']
- self.book_ode = self.Book.create({
- 'name': 'Odoo developdfjklajdflkajflkaj',
- 'isbn': '9787530220245'
- })
- return result
-
- def test_create(self):
- "Test Books are active by default"
- self.assertEqual(self.book_ode.active, True)
-
-
- def test_check_isbn(self):
- "Check valid ISBN"
- self.assertTrue(self.book_ode._check_isbn())
-
- def test_button_check_isbn(self):
- "Button Check ISBN"
- self.assertTrue(self.book_ode.button_check_isbn())
-
-
- def test_isbn_invalid(self):
- "Button Check ISBN IF 1"
- self.book_ode.isbn = '1'
- with self.assertRaises(UserError):
- self.assertRaises(self.book_ode.button_check_isbn())
-
-
- def test_isbn_blank(self):
- "Button Check ISBN IF 2"
- self.book_ode.isbn = ''
- with self.assertRaises(UserError):
- self.assertRaises(self.book_ode.button_check_isbn())
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- class Test_SurveyCase(HttpCase):
- def test_access_page(self):
- self.authenticate("admin", "1")
- return self.url_open('/library/books')
|