Skip to content

Commit 88f5d92

Browse files
author
Prabhu
committed
Added unit tests
1 parent c74ef6f commit 88f5d92

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

addressbook.py

-10
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,3 @@ def _getVal(tmpval):
7878
elif type(tmpval) == NSCFDictionary:
7979
aval = dict([(k.lower(), tmpval[k]) for k in tmpval.keys()])
8080
return aval
81-
82-
def main():
83-
#print all()
84-
#print groups()
85-
#print me()
86-
#print getByUID('B50984C8-FEAC-4D6A-8B77-E271DB729A8E:ABPerson')
87-
88-
if __name__ == '__main__':
89-
main()
90-

tests.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
"""
4+
tests.py
5+
6+
Unit test cases for addressbook
7+
"""
8+
import unittest
9+
import addressbook
10+
11+
class tests(unittest.TestCase):
12+
13+
def testAll(self):
14+
""" Test retrieving all records """
15+
self.assert_(addressbook.all())
16+
17+
def testGroups(self):
18+
""" Test retrieving groups """
19+
self.assert_(addressbook.groups())
20+
21+
def testMe(self):
22+
""" Test retrieving current user """
23+
self.assert_(addressbook.me())
24+
25+
def testGetByUID(self):
26+
""" Test getByUID """
27+
allr = addressbook.all()
28+
for a in allr:
29+
self.assert_(addressbook.getByUID(a['uid']))
30+
break
31+
32+
if __name__ == '__main__':
33+
suite = unittest.TestLoader().loadTestsFromTestCase(tests)
34+
unittest.TextTestRunner(verbosity=2).run(suite)

0 commit comments

Comments
 (0)