How to use _mail method in autotest

Best Python code snippet using autotest_python

test_module_users.py

Source:test_module_users.py Github

copy

Full Screen

1''' test module/user '''2import pytest3from models.oauth_db import OAuthDB4from module.users import User5@pytest.fixture(scope='module', params=[None, 'coscup'])6def uid(request):7 ''' uid '''8 return request.param9@pytest.fixture(scope='module', params=[None, 'coscup@coscup.org'])10def mail(request):11 ''' mail '''12 return request.param13class TestUser: # pylint: disable=too-few-public-methods14 ''' Test User '''15 @staticmethod16 def test_init(uid, mail): # pylint: disable=redefined-outer-name17 ''' test init '''18 user = User(uid=uid, mail=mail)19 assert user.uid == uid20 assert user.mail == mail21 @staticmethod22 def test_get():23 ''' Test get '''24 user = User(uid='coscup')25 user.get()26 @staticmethod27 def test_create_and_oauth():28 ''' test create user '''29 _mail = 'coscup@coscup.org'30 with pytest.raises(Exception) as error:31 User.create(mail=_mail)32 assert str(error.value) == f'mail: `{_mail}` not in the oauth dbs'33 OAuthDB().add_data(mail=_mail, data={})34 OAuthDB().find_one_and_update(35 {'_id': _mail}, {'$set': {'owner': '00000000'}})36 with pytest.raises(Exception) as error:37 User.create(mail=_mail)38 assert str(error.value) == f'mail:`{_mail}` already bind'39 @staticmethod40 def test_create_success():41 ''' Test create user success '''42 _mail = 'coscup+success@coscup.org'43 OAuthDB().add_data(mail=_mail, data={})44 created_user = User.create(mail=_mail)45 assert created_user['mail'] == _mail46 @staticmethod47 def test_update_profile():48 ''' Test update profile '''49 _mail = 'coscup+updateprofile@coscup.org'50 OAuthDB().add_data(mail=_mail, data={})51 created_user = User.create(mail=_mail)52 data = {'nickname': 'nick coscup'}53 updated_user = User(uid=created_user['_id']).update_profile(data=data)54 assert updated_user['profile']['nickname'] == 'nick coscup'55 real_data = {'name': 'COSCUP'}56 updated_user = User(57 uid=created_user['_id']).update_profile_real(data=real_data)58 assert updated_user['profile_real']['name'] == 'COSCUP'59 suspend_user = User(uid=created_user['_id']).property_suspend()...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

1import unittest2import utils3import MailPrototype4from Models import Mail5class TestUtils(unittest.TestCase):6 def test_hash(self):7 self.assertEqual(utils.hash("test-Hash-function"), utils.hash("test-Hash-function"),8 "The result of the hash function is different on same plaintext.")9class TestMail(unittest.TestCase):10 def test_mail_class(self):11 _mail = Mail()12 _mail.setFrom("test@test.com")13 _mail.setTo("tester@test.com")14 _mail.setSubject("TEST")15 _mail.setBody("This is just a test.")16 self.assertEqual(_mail.getFrom(), "test@test.com",17 "Mail._from should be \'test@test.com\'")18 self.assertEqual(_mail.getTo(), "tester@test.com",19 "Mail._to should be \'tester@test.com\'")20 self.assertEqual(_mail.getSubject(), "TEST",21 "Mail._subject should be \'TEST\'")22 self.assertEqual(_mail.getBody(), "This is just a test.",23 "Mail._body should be \'This is just a test.\'")24class TestMailPrototype(unittest.TestCase):25 def test_mailprototype(self):26 _mail = Mail()27 _mail.setFrom("test@test.com")28 _mail.setTo("tester@test.com")29 _mail.setSubject("TEST")30 _mail.setBody("This is just a test.")31 draft_mail = MailPrototype.Draft(_mail)32 forward_mail = MailPrototype.Forward(_mail)33 sent_mail = MailPrototype.Sent(_mail)34 self.assertEqual(draft_mail.clone().getType(),35 "Draft", "Should be of type \'Draft\'.")36 self.assertEqual(forward_mail.clone().getType(),37 "Forward", "Should be of type \'Forward\'.")38 self.assertEqual(sent_mail.clone().getType(),39 "Sent", "Should be of type \'Sent\'.")40if __name__ == '__main__':...

Full Screen

Full Screen

__dispatcher.py

Source:__dispatcher.py Github

copy

Full Screen

...16 def __init__(self):17 self._outlook = win32.dynamic.Dispatch('Outlook.Application')18 self._mail = None19 def send(self, mail: Mail) -> bool:20 self._create_new_mail(mail)21 try:22 self._mail.Send() 23 return True24 except Exception as e:25 print(e, 'erro send')26 return False27 def preview(self, mail: Mail):28 self._create_new_mail(mail)29 self._mail.Display(True)30 31 def _add_attachments(self, mail: Mail):32 for attach in mail.Attachments:33 if not os.path.isfile(attach):34 raise Exception(f'{attach} It\'s not a valid file')35 self._mail.Attachments.Add(Source=attach)36 37 def _add_copies(self, mail: Mail):38 self._mail.CC = mail.CC39 def _add_signature(self):40 self._mail.GetInspector.Activate()41 42 def _create_new_mail(self, mail: Mail):43 self._mail = self._outlook.CreateItem(0)44 self._mail.Subject = mail.Subject45 self._mail.To = mail.To46 if mail.CC:47 self._add_copies(mail)48 if mail.Signature:49 self._add_signature()50 self._mail.HTMLBody = mail.HTMLBody + self._mail.HTMLBody51 if mail.Attachments:52 self._add_attachments(mail)53 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful