Пример #1
0
 def test_add_field(self):
     field = TextField('foo', field_uri='bar')
     Item.add_field(field, insert_after='subject')
     try:
         self.assertEqual(Item.get_field_by_fieldname('foo'), field)
     finally:
         Item.remove_field(field)
Пример #2
0
 def test_add_field(self):
     field = TextField("foo", field_uri="bar")
     Item.add_field(field, insert_after="subject")
     try:
         self.assertEqual(Item.get_field_by_fieldname("foo"), field)
     finally:
         Item.remove_field(field)
Пример #3
0
    def test_invalid_field(self):
        test_field = Item.get_field_by_fieldname(fieldname='text_body')
        self.assertIsInstance(test_field, TextField)
        self.assertEqual(test_field.name, 'text_body')

        with self.assertRaises(InvalidField):
            Item.get_field_by_fieldname(fieldname='xxx')

        Item.validate_field(field=test_field, version=Version(build=EXCHANGE_2013))
        with self.assertRaises(InvalidFieldForVersion) as e:
            Item.validate_field(field=test_field, version=Version(build=EXCHANGE_2010))
        self.assertEqual(
            e.exception.args[0],
            "Field 'text_body' is not supported on server version Build=14.0.0.0, API=Exchange2010, Fullname=Microsoft "
            "Exchange Server 2010 (supported from: 15.0.0.0, deprecated from: None)"
        )