Changeset 10:d5329a2a05b7 in mailjam for postman/tests
- Timestamp:
- May 20, 2012, 9:39:51 AM (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- postman/tests
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
postman/tests/daemon.py
r9 r10 1 1 # -*- coding: utf-8 -*- 2 2 3 import os, multiprocessing, xmlrpclib 3 import os, multiprocessing, xmlrpclib, time 4 4 from SimpleXMLRPCServer import SimpleXMLRPCServer 5 5 from unittest import TestCase … … 18 18 """ 19 19 def setUp(self): 20 config = {'private': False, 'archive': '/tmp/postman-tests/archive', 21 'storage': '/tmp/postman-tests/storage'} 20 self.configfile = os.path.join(os.path.dirname(__file__), 'postman.conf') 22 21 self.mailing_list = MailingList('test_list', 'test_list@example.com', 23 members={}, config =config)22 members={}, configfile=self.configfile) 24 23 self.member = Member('test@example.com') 25 24 26 25 def test___init__(self): 27 postman = Postman( )26 postman = Postman(configfile=self.configfile) 28 27 self.assertIsInstance(postman, Postman) 29 28 self.assertEqual(postman.mailings, {}) … … 36 35 37 36 def test_save(self): 38 postman = Postman( )37 postman = Postman(configfile=self.configfile) 39 38 self.assertFalse(postman.save()) 40 39 postman.add_mailing_list(self.mailing_list.info()) … … 47 46 48 47 def test_load(self): 49 postman = Postman( )48 postman = Postman(configfile=self.configfile) 50 49 self.assertFalse(postman.mailings) 51 50 self.assertFalse(postman.mailings_addresses) … … 55 54 56 55 # Check that another postman instance is able to load the saved data 57 postman_load = Postman( )56 postman_load = Postman(configfile=self.configfile) 58 57 self.assertFalse(postman_load.mailings) 59 58 self.assertFalse(postman_load.mailings_addresses) … … 68 67 69 68 def test_clear(self): 70 postman = Postman( )69 postman = Postman(configfile=self.configfile) 71 70 self.assertFalse(postman.clear()) 72 71 postman.add_mailing_list(self.mailing_list.info()) … … 74 73 75 74 def test_add_mailing_list(self): 76 postman = Postman( )75 postman = Postman(configfile=self.configfile) 77 76 with self.assertRaises(TypeError): 78 77 # test improper info values … … 100 99 101 100 def test_add_mailing_member(self): 102 postman = Postman( )101 postman = Postman(configfile=self.configfile) 103 102 postman.add_mailing_list(self.mailing_list.info()) 104 103 with self.assertRaises(ValueError): … … 133 132 """ 134 133 def setUp(self): 135 config = {'private': False, 'archive': '/tmp/postman-tests/archive', 136 'storage': '/tmp/postman-tests/storage'} 137 self.mailing_list = MailingList('test_xmlrpc', 'test_xmlrpc@example.com', 138 members={}, config=config) 134 self.configfile = os.path.join(os.path.dirname(__file__), 135 'postman.conf') 136 self.mailing_list = MailingList('test_xmlrpc', 137 'test_xmlrpc@example.com', members={}, 138 configfile=self.configfile) 139 139 self.member = Member('test@example.com') 140 140 141 141 def test___init__(self): 142 daemon = PostmanDaemon( )142 daemon = PostmanDaemon(self.configfile) 143 143 self.assertIsInstance(daemon, PostmanDaemon) 144 144 self.assertFalse(daemon.ready_to_serve) … … 147 147 148 148 def test_create_server(self): 149 daemon = PostmanDaemon( )149 daemon = PostmanDaemon(self.configfile) 150 150 daemon.port = 9001 151 151 self.assertTrue(daemon.create_server()) … … 154 154 155 155 def test_add_methods(self): 156 daemon = PostmanDaemon( )156 daemon = PostmanDaemon(self.configfile) 157 157 daemon.port = 9002 158 158 self.assertTrue(daemon.add_methods()) 159 159 self.assertTrue(daemon.ready_to_serve) 160 160 161 daemon = PostmanDaemon( )161 daemon = PostmanDaemon(self.configfile) 162 162 daemon.port = 9003 163 163 daemon.create_server() … … 166 166 167 167 def test_run(self): 168 daemon = PostmanDaemon( )168 daemon = PostmanDaemon(self.configfile) 169 169 daemon.port = 9004 170 170 # start the daemon in another process, so we can start communicating … … 172 172 p = multiprocessing.Process(target=daemon.run) 173 173 p.start() 174 175 # Add a delay here to allow the server to be fully started before 176 # starting to send requests from the client 177 time.sleep(2) 174 178 175 179 # FIXME: Hardcoded url here, should be picked from a config file -
postman/tests/models.py
r1 r10 1 1 # -*- coding: utf-8 -*- 2 2 3 import os 3 4 from unittest import TestCase 4 5 from postman.models import Member, MailingList … … 18 19 class TestMailingList(TestCase): 19 20 def setUp(self): 20 config = {'private': False, 'archive': '/tmp/postman-tests/archive', 21 'storage': '/tmp/postman-tests/storage'} 21 configfile = os.path.join(os.path.dirname(__file__), 'postman.conf') 22 22 self.mailing_list = MailingList('test_list', 'test_list@example.com', 23 members={}, config =config)23 members={}, configfile=configfile) 24 24 self.member = Member('test@example.com') 25 25 -
postman/tests/mta.py
r5 r10 6 6 from postman.models import Member, MailingList 7 7 8 9 8 class TestSendmail(TestCase): 10 9 def setUp(self): 11 config = {'private': False, 'archive': '/tmp/postman-tests/archive',12 'storage': '/tmp/postman-tests/storage'}10 self.configfile = os.path.join(os.path.dirname(__file__), 11 'postman.conf') 13 12 self.mailing_list = MailingList('test_list', 'test_list@example.com', 14 members={}, config =config)13 members={}, configfile=self.configfile) 15 14 self.member = Member('test@example.com') 16 15 self.mta = Sendmail(self.mailing_list)
Note:
See TracChangeset
for help on using the changeset viewer.