source: TI12-security/trunk/python/Tests/LogClientTest.py @ 1771

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/LogClientTest.py@2556
Revision 1771, 2.6 KB checked in by pjkersha, 13 years ago (diff)

Replaced references to 'PubKey?' with 'Cert' as this is more accurate - they refer to X.509 certs which
contain public keys.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3"""Test harness for NDG logging client - send log messages to WS
4
5NERC Data Grid Project
6
7P J Kershaw 12/05/06
8
9
10Copyright (C) 2006 CCLRC & NERC
11
12This software may be distributed under the terms of the Q Public License,
13version 1.0 or later.
14"""
15import unittest
16import os
17
18from ndg.security.LogClient import *
19
20
21class LogClientTestCase(unittest.TestCase):
22   
23    def setUp(self):
24        try:
25            # Session Manager WSDL
26            wsdl = '../www/html/log.wsdl'
27   
28           
29            # Initialise the client connection
30            # Omit traceFile keyword to leave out SOAP debug info
31            self.logClnt = LogClient(wsdl=wsdl, 
32                 signingCertFilePath="./Junk-cert.pem",
33                 signingPriKeyFilePath="./Junk-key.pem",
34                 signingPriKeyPwd=open("./tmp2").read().strip(), 
35                 traceFile=sys.stderr) 
36
37        except Exception, e:
38            self.fail(str(e))
39           
40           
41    def tearDown(self):
42        pass
43
44
45    def test1Debug(self):
46       
47        msg = \
48"Never mind that, my lad. I wish to complain about this parrot what I purchased not half an hour ago from this very boutique."
49       
50        try:
51            self.logClnt.debug(msg)
52           
53        except Exception, e:
54            self.fail(str(e))
55
56
57    def test2Info(self):
58       
59        msg = \
60"Oh yes, the, uh, the Norwegian Blue...What's,uh...What's wrong with it?"
61       
62        try:
63            self.logClnt.info(msg)
64           
65        except Exception, e:
66            self.fail(str(e))
67
68
69    def test3Warning(self):
70       
71        msg = \
72"I'll tell you what's wrong with it, my lad. 'E's dead, that's what's wrong with it!"
73       
74        try:
75            self.logClnt.warning(msg)
76           
77        except Exception, e:
78            self.fail(str(e))
79
80
81    def test4Error(self):
82       
83        msg = "No, no, 'e's uh,...he's resting."
84       
85        try:
86            self.logClnt.error(msg)
87           
88        except Exception, e:
89            self.fail(str(e))
90           
91           
92#_____________________________________________________________________________       
93class LogClientTestSuite(unittest.TestSuite):
94   
95    def __init__(self):
96        logTestMap = map(LogClientTestCase,
97                  (
98                    "test1Debug",
99                    "test2Info",
100                    "test3Warning",
101                    "test4Error",
102                  ))
103        unittest.TestSuite.__init__(self, logTestMap)
104           
105                                                   
106if __name__ == "__main__":
107    unittest.main()       
Note: See TracBrowser for help on using the repository browser.