Example #1
0
 def test_copy(self):
     sd = SafeDict.MsgSafeDict(self._msg, {'foo': 'bar'})
     copy = sd.copy()
     items = list(copy.items())
     items.sort()
     self.assertEqual(items, [
         ('allmsg_cc', '[email protected], [email protected]'),
         ('foo', 'bar'),
         ('msg_from', 'bar'),
         ('msg_subject', 'baz'),
         ('msg_to', 'foo'),
     ])
Example #2
0
 def test_allmsg_key(self):
     sd = SafeDict.MsgSafeDict(self._msg, {'cc': 'value'})
     si = '%(allmsg_cc)s' % sd
     self.assertEqual(si, '[email protected], [email protected]')
Example #3
0
 def test_allmsg_no_key(self):
     sd = SafeDict.MsgSafeDict(self._msg)
     si = '%(allmsg_date)s' % sd
     self.assertEqual(si, 'n/a')
Example #4
0
 def test_msg_key(self):
     sd = SafeDict.MsgSafeDict(self._msg, {'to': 'value'})
     si = '%(msg_to)s' % sd
     self.assertEqual(si, 'foo')
Example #5
0
 def test_normal_key(self):
     sd = SafeDict.MsgSafeDict(self._msg, {'key': 'value'})
     si = '%(key)s' % sd
     self.assertEqual(si, 'value')
Example #6
0
 def test_key_error_not_string(self):
     key = ()
     sd = SafeDict.SafeDict({})
     self.assertEqual(sd[key], '<Missing key: ()>')
Example #7
0
 def test_key_error(self):
     sd = SafeDict.SafeDict({'foo': 'bar'})
     si = '%(baz)s' % sd
     self.assertEqual(si, '%(baz)s')
Example #8
0
 def test_okay(self):
     sd = SafeDict.SafeDict({'foo': 'bar'})
     si = '%(foo)s' % sd
     self.assertEqual(si, 'bar')