Пример #1
0
 def __init__(self, author=None, to=None, subject=None, **kw):
     """Instantiate a new Message object.
     
     No arguments are required, as everything can be set using class
     properties.  Alternatively, __everything__ can be set using the
     constructor, using named arguments.  The first three positional
     arguments can be used to quickly prepare a simple message.
     """
     
     # Internally used attributes.
     
     self._id = None
     self._processed = False
     self._dirty = False
     self.mailer = None
     
     # Default values.
     
     self.subject = None
     self.date = datetime.now()
     self.encoding = 'utf-8'
     self.organization = None
     self.priority = None
     self.plain = None
     self.rich = None
     self.attachments = []
     self.embedded = []
     self.headers = []
     self.retries = 3
     self.brand = True
     
     self._sender = None
     self._author = AddressList()
     self._to = AddressList()
     self._cc = AddressList()
     self._bcc = AddressList()
     self._reply = AddressList()
     self._notify = AddressList()
     
     # Overrides at initialization time.
     
     if author is not None:
         self.author = author
     
     if to is not None:
         self.to = to
     
     if subject is not None:
         self.subject = subject
     
     for k in kw:
         if not hasattr(self, k):
             raise TypeError("Unexpected keyword argument: %s" % k)
         
         setattr(self, k, kw[k])
Пример #2
0
 def test_permit_one_sender_at_most(self):
     message = self.build_message()
     message.sender = AddressList(['*****@*****.**', '*****@*****.**'])
Пример #3
0
	def test_address_from_addresslist_limit_2(self):
		email = '*****@*****.**'
		
		with pytest.raises(ValueError):
			Address(AddressList([Address(email), Address(email)]))
Пример #4
0
	def test_addresses(self):
		self.addresses = [('Test User 1', '*****@*****.**'), ('Test User 2', '*****@*****.**')]
		assert self.addresses.addresses == AddressList('[email protected], [email protected]')
Пример #5
0
	def test_address_from_addresslist_limit_0(self):
		with pytest.raises(ValueError):
			Address(AddressList())
Пример #6
0
 def setUp(self):
     self.addresses = AddressList()
Пример #7
0
	def test_invalid_init(self):
		with pytest.raises(ValueError):
			AddressList(2)
Пример #8
0
	def setup_method(self, method):
		self.addresses = AddressList()
Пример #9
0
	def test_address_from_addresslist(self):
		email = '*****@*****.**'
		addr = Address(AddressList([Address(email)]))
		assert unicode(addr) == email
Пример #10
0
 def test_address_from_addresslist_limit_2(self):
     email = '*****@*****.**'
     addr = Address(AddressList([Address(email), Address(email)]))
Пример #11
0
	def setup_class(cls):
		cls._addresses = AddressList()
Пример #12
0
 def test_address_from_addresslist_limit_0(self):
     email = '*****@*****.**'
     addr = Address(AddressList())
Пример #13
0
 def test_invalid_init(self):
     AddressList(2)
Пример #14
0
 def test_init_accepts_tuple(self):
     addresses = AddressList(('foo', '*****@*****.**'))
     eq_([('foo', '*****@*****.**')], addresses)
Пример #15
0
	def recipients(self):
		return AddressList(self.to + self.cc + self.bcc)
Пример #16
0
	def test_init_accepts_tuple(self):
		addresses = AddressList(('foo', '*****@*****.**'))
		assert addresses == [('foo', '*****@*****.**')]
Пример #17
0
 def test_permit_one_sender_at_most(self):
     with pytest.raises(ValueError):
         message = self.build_message()
         message.sender = AddressList(
             ['*****@*****.**', '*****@*****.**'])
Пример #18
0
 def __init__(self):
     self._addresses = AddressList()