1 | import unittest |
---|
2 | |
---|
3 | #from zope.testing import doctestunit |
---|
4 | #from zope.component import testing |
---|
5 | from Testing import ZopeTestCase as ztc |
---|
6 | |
---|
7 | from Products.Five import fiveconfigure |
---|
8 | from Products.PloneTestCase import PloneTestCase as ptc |
---|
9 | from Products.PloneTestCase.layer import PloneSite |
---|
10 | ptc.setupPloneSite() |
---|
11 | |
---|
12 | import quintagroup.gauth |
---|
13 | |
---|
14 | |
---|
15 | class TestCase(ptc.PloneTestCase): |
---|
16 | |
---|
17 | class layer(PloneSite): |
---|
18 | |
---|
19 | @classmethod |
---|
20 | def setUp(cls): |
---|
21 | fiveconfigure.debug_mode = True |
---|
22 | ztc.installPackage(quintagroup.gauth) |
---|
23 | fiveconfigure.debug_mode = False |
---|
24 | |
---|
25 | @classmethod |
---|
26 | def tearDown(cls): |
---|
27 | pass |
---|
28 | |
---|
29 | |
---|
30 | # class SafeQuery(object): |
---|
31 | # def safeCall(self, serv, meth, methargs=[], methkwargs={}): |
---|
32 | # print "safecall %s: serv: %s, meth: %s, methargs: %s, methkwargs: %s" % ( |
---|
33 | # self, serv, meth, methargs, methkwargs) |
---|
34 | # try: |
---|
35 | # return meth(*methargs, **methkwargs) |
---|
36 | # except gdata.service.RequestError, e: |
---|
37 | # print "Token Expired -> Update it." |
---|
38 | # logException("Token Expired -> Update it.") |
---|
39 | # serv.ProgrammaticLogin() |
---|
40 | # return meth(*methargs, **methkwargs) |
---|
41 | # counter = 0 |
---|
42 | # class DummyServ: |
---|
43 | # def ProgrammaticLogin(self, captcha_token=None, captcha_response=None): |
---|
44 | # print "for '%s' called ProgrammaticLogin" % str(self) |
---|
45 | # def Query(self, *args, **kwargs): |
---|
46 | # global counter |
---|
47 | # if counter > 3: |
---|
48 | # counter = 0 |
---|
49 | # raise gdata.service.RequestError("Some Problem in Query") |
---|
50 | # print "for '%s' called Query with args: %s, kwargs: %s" % tuple( |
---|
51 | # map(str,[self,args,kwargs])) |
---|
52 | # counter += 1 |
---|
53 | # class C(SafeQuery): |
---|
54 | # serv = None |
---|
55 | # def __init__(self): |
---|
56 | # self.serv = DummyServ() |
---|
57 | # def operation(self, a): |
---|
58 | # for i in range(5): |
---|
59 | # self.safeCall(self.serv, self.serv.Query, [i,], {"q": i*i}) |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | def test_suite(): |
---|
67 | return unittest.TestSuite([ |
---|
68 | |
---|
69 | # Unit tests |
---|
70 | #doctestunit.DocFileSuite( |
---|
71 | # 'README.txt', package='quintagroup.gauth', |
---|
72 | # setUp=testing.setUp, tearDown=testing.tearDown), |
---|
73 | |
---|
74 | #doctestunit.DocTestSuite( |
---|
75 | # module='quintagroup.gauth.mymodule', |
---|
76 | # setUp=testing.setUp, tearDown=testing.tearDown), |
---|
77 | |
---|
78 | |
---|
79 | # Integration tests that use PloneTestCase |
---|
80 | #ztc.ZopeDocFileSuite( |
---|
81 | # 'README.txt', package='quintagroup.gauth', |
---|
82 | # test_class=TestCase), |
---|
83 | |
---|
84 | #ztc.FunctionalDocFileSuite( |
---|
85 | # 'browser.txt', package='quintagroup.gauth', |
---|
86 | # test_class=TestCase), |
---|
87 | |
---|
88 | ]) |
---|
89 | |
---|
90 | if __name__ == '__main__': |
---|
91 | unittest.main(defaultTest='test_suite') |
---|