~ubuntu-branches/debian/sid/openchange/sid

« back to all changes in this revision

Viewing changes to pyopenchange/unittest/unittest_pymapi.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-12 20:07:57 UTC
  • mfrom: (11 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20120412200757-k933d9trljmxj1l4
Tags: 1:1.0-4
* openchangeserver: Add dependency on openchangeproxy.
* Rebuild against newer version of Samba 4.
* Use dpkg-buildflags.
* Migrate to Git, update Vcs-Git header.
* Switch to debhelper 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
# -*- coding: utf-8 -*-
3
 
 
4
 
from openchange import mapi
5
 
import time
6
 
 
7
 
import unittest
8
 
 
9
 
class TestMapi(unittest.TestCase):
10
 
        def setUp(self):
11
 
                self.SPropValue = mapi.SPropValue()
12
 
                pass
13
 
 
14
 
        def test_noargs(self): # we need two args
15
 
                self.assertRaises(TypeError, self.SPropValue.add)
16
 
                
17
 
        def test_onearg(self): # we need two args
18
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagGender)
19
 
 
20
 
        def test_i2(self):
21
 
                self.SPropValue.add(mapi.PidTagGender, 3)
22
 
 
23
 
        def test_i2_duplicate(self):
24
 
                self.SPropValue.add(mapi.PidTagGender, 3)
25
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagGender, 2)
26
 
 
27
 
        def test_i2_wrong_type(self):
28
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagGender, "wrong type for I2")
29
 
 
30
 
        def test_long(self):
31
 
                self.SPropValue.add(mapi.PidTagImportance, 4096)
32
 
 
33
 
        def test_long_duplicate(self):
34
 
                self.SPropValue.add(mapi.PidTagImportance, 4096)
35
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagImportance, 4097)
36
 
 
37
 
        def test_long_wrong_type(self):
38
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagImportance, "wrong type for long")
39
 
 
40
 
        def test_double(self):
41
 
                self.SPropValue.add(0x8F010005, 3.1415) # PT_DOUBLE
42
 
 
43
 
        def test_double_duplicate(self):
44
 
                self.SPropValue.add(0x8F010005, 3.1415) # PT_DOUBLE
45
 
                self.assertRaises(TypeError, self.SPropValue.add, 0x8F010005, 42.7)
46
 
 
47
 
        def test_double_wrong_type(self):
48
 
                self.assertRaises(TypeError, self.SPropValue.add, 0x8F010005, "wrong type for double")
49
 
 
50
 
        def test_errortype(self):
51
 
                self.SPropValue.add(mapi.PidTagGivenName_Error, 0x80040502)
52
 
 
53
 
        def test_errortype_duplicate(self):
54
 
                self.SPropValue.add(mapi.PidTagGivenName_Error, 0x80040502)
55
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagGivenName_Error, 0x80040305)
56
 
 
57
 
        def test_errortype_wrong_type(self):
58
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagGivenName_Error, "wrong type for error")
59
 
 
60
 
        def test_boolean(self):
61
 
                self.SPropValue.add(mapi.PidTagProcessed, True)
62
 
 
63
 
        def test_boolean_duplicate(self):
64
 
                self.SPropValue.add(mapi.PidTagProcessed, True)
65
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagProcessed, True)
66
 
 
67
 
        def test_boolean_wrong_type(self):
68
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagProcessed, "wrong type for boolean")
69
 
 
70
 
        def test_i8(self):
71
 
                self.SPropValue.add(mapi.PidTagInstID, 0x12345678L)
72
 
 
73
 
        def test_i8_duplicate(self):
74
 
                self.SPropValue.add(mapi.PidTagInstID, 0x12345678L)
75
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagInstID, 0x12345677L)
76
 
 
77
 
        def test_i8_wrong_type(self):
78
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagInstID, "wrong type for I8")
79
 
 
80
 
        def test_string8(self):
81
 
                self.SPropValue.add(mapi.PidTagAddressBookHierarchicalRootDepartment, "Development")
82
 
 
83
 
        def test_string8_duplicate(self):
84
 
                self.SPropValue.add(mapi.PidTagAddressBookHierarchicalRootDepartment, "Development")
85
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagAddressBookHierarchicalRootDepartment, "Research")
86
 
 
87
 
        def test_string8_wrong_type(self):
88
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagAddressBookHierarchicalRootDepartment, 423) # wrong type
89
 
 
90
 
        def test_unicode(self):
91
 
                self.SPropValue.add(mapi.PidTagComment, "value of the comment")
92
 
 
93
 
        def test_unicode_duplicate(self):
94
 
                self.SPropValue.add(mapi.PidTagComment, "value of the comment")
95
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagComment, "duplicate")
96
 
 
97
 
        def test_unicode_wrong_type(self):
98
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagComment, 3) # wrong type
99
 
 
100
 
        def test_filetime(self):
101
 
                self.SPropValue.add(mapi.PidTagStartDate, time.time())
102
 
 
103
 
        def test_filetime_duplicate(self):
104
 
                self.SPropValue.add(mapi.PidTagStartDate, time.time())
105
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagStartDate, time.time())
106
 
 
107
 
        def test_filetime_wrong_type(self):
108
 
                self.assertRaises(TypeError, self.SPropValue.add, mapi.PidTagStartDate, "wrong type for time")
109
 
 
110
 
        def test_dump_no_entries(self):
111
 
                self.SPropValue.dump("test_dump_no_entries:")
112
 
                
113
 
        def test_dump_one_entry(self):
114
 
                self.SPropValue.add(mapi.PidTagComment, "value of the comment")
115
 
                self.SPropValue.dump("test_dump_one_entry:")
116
 
        
117
 
        def test_bad_type(self):
118
 
                self.assertRaises(TypeError, self.SPropValue.add, 0x12340000, 1) # 0000 isn't a valid property type
119
 
 
120
 
        def test_dump_multiple_entries(self):
121
 
                self.SPropValue.add(mapi.PidTagGender, 3)
122
 
                self.SPropValue.add(mapi.PidTagImportance, 4096)
123
 
                self.SPropValue.add(0x8F010005, 3.1415) # PT_DOUBLE
124
 
                self.SPropValue.add(mapi.PidTagGivenName_Error, 0x80040502)
125
 
                self.SPropValue.add(mapi.PidTagProcessed, True)
126
 
                self.SPropValue.add(mapi.PidTagInstID, 0x12345678L)
127
 
                self.SPropValue.add(mapi.PidTagAddressBookHierarchicalRootDepartment, "Development")
128
 
                self.SPropValue.add(mapi.PidTagComment, "value of the comment")
129
 
                self.SPropValue.add(mapi.PidTagStartDate, time.time())
130
 
                self.SPropValue.dump("test_dump_multiple_entries:")
131
 
                
132
 
        # we need at least one argument, should raise an error if no args
133
 
        def test_dump_no_args(self):
134
 
                self.assertRaises(TypeError, self.SPropValue.dump)
135
 
 
136
 
        def tearDown(self):
137
 
                del(self.SPropValue)
138
 
 
139
 
if __name__ == '__main__':
140
 
        unittest.main()