Source

trytond-electronic_mail / tests / test_electronic_mail.py

Diff from to

tests/test_electronic_mail.py

     def setUp(self):
         trytond.tests.test_tryton.install_module('electronic_mail')
 
-        self.mailbox_obj = POOL.get('electronic_mail.mailbox')
-        self.mail_obj = POOL.get('electronic_mail')
-        self.header_obj = POOL.get('electronic_mail.header')
-        self.user_obj = POOL.get('res.user')
-        self.groups_obj = POOL.get('res.group')
-        self.ir_model_data_obj = POOL.get('ir.model.data')
+        self.Mailbox = POOL.get('electronic_mail.mailbox')
+        self.Mail = POOL.get('electronic_mail')
+        self.Header = POOL.get('electronic_mail.header')
+        self.ModelData = POOL.get('ir.model.data')
 
     def create_user(self, name):
         """
         Creates a new user and returns the ID
         """
-        group_email_admin_id =  self.ir_model_data_obj.get_id(
+        group_email_admin_id =  self.ModelData.get_id(
             'electronic_mail', 'group_email_admin')
-        group_email_user_id =  self.ir_model_data_obj.get_id(
+        group_email_user_id =  self.ModelData.get_id(
             'electronic_mail', 'group_email_user')
 
-        return self.user_obj.create(
+        return self.User.create(
             {
             'login': name,
             'name': name,
             # Create Users for testing access
             user_set_1, user_set_2 = self.create_users(no_of_sets=2)
             # Create a mailbox with a user set
-            self.mailbox_obj.create(
+            self.Mailbox.create(
                 {
                     'name': 'Parent Mailbox',
                     'user': user_set_1[0],
                     })
 
             # Create a mailbox 2 with RW users of set 1 + set 2
-            self.mailbox_obj.create(
+            self.Mailbox.create(
                 {
                     'name': 'Child Mailbox',
                     'user': user_set_2[0],
             for user_id, mailbox_count in expected_results.items():
                 with Transaction().set_user(user_id):
                     self.assertEqual(
-                        self.mailbox_obj.search([], count=True),
+                        self.Mailbox.search([], count=True),
                         mailbox_count
                     )
 
         """
         with Transaction().start(DB_NAME, USER, CONTEXT) as transaction:
             user_o, user_r, user_w = self.create_users(no_of_sets=1)[0]
-            mailbox = self.mailbox_obj.create(
+            mailbox = self.Mailbox.create(
                 {
                     'name': 'Mailbox',
                     'user': user_o,
             # Raise exception when writing a mail with the read user
             with Transaction().set_user(user_r):
                 self.assertRaises(
-                    Exception, self.mail_obj.create,
+                    Exception, self.Mail.create,
                     ({
                         'from_': 'Test',
                         'mailbox': mailbox
             # Creating mail with the write user
             with Transaction().set_user(user_w):
                 self.assert_(
-                    self.mail_obj.create({'from_': 'Test', 'mailbox': mailbox})
+                    self.Mail.create({'from_': 'Test', 'mailbox': mailbox})
                 )
 
             # Create an email as mailbox owner
             with Transaction().set_user(user_o):
                 self.assert_(
-                    self.mail_obj.create({'from_': 'Test', 'mailbox': mailbox})
+                    self.Mail.create({'from_': 'Test', 'mailbox': mailbox})
                 )
 
             transaction.cursor.rollback()
         message.attach(part2)
 
         with Transaction().start(DB_NAME, USER, CONTEXT):
-            mailbox = self.mailbox_obj.create(
+            mailbox = self.Mailbox.create(
                 {
                     'name': 'Mailbox',
                     'user': USER,
                     'read_users': [('set', [USER])],
                     'write_users': [('set', [USER])],
                     })
-            mail_id = self.mail_obj.create_from_email(message, mailbox)
-            mail = self.mail_obj.browse(mail_id)
+            mail_id = self.Mail.create_from_email(message, mailbox)
+            mail = self.Mail.browse(mail_id)
 
             self.assertEqual(mail.subject, message['Subject'])
             self.assertEqual(mail.from_, message['From'])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.