source: componentdependencyplugin/0.11/componentdependencies/test.py

Last change on this file was 17562, checked in by Ryan J Ollos, 4 years ago

Make compatible with Trac 1.4

File size: 1.5 KB
Line 
1"""
2test class for ComponentDependencyPlugin
3"""
4
5from trac.core import *
6from trac.web import IRequestHandler
7
8from componentdependencies import IRequireComponents
9
10__all__ = [ 'FooBarTest', 'TestDependencyPlugin', ]
11
12
13class FooBarTest(Component):
14
15    def foobar(self):
16        return "hello world"
17
18class TestDependencyPlugin(Component):
19
20    implements(IRequestHandler, IRequireComponents)
21
22    ### methods for IRequestHandler
23
24    def match_request(self, req):
25        """Return whether the handler wants to process the given request."""
26        return req.path_info == '/hello-world'
27
28
29    def process_request(self, req):
30        """Process the request. For ClearSilver, return a (template_name,
31        content_type) tuple, where `template` is the ClearSilver template to use
32        (either a `neo_cs.CS` object, or the file name of the template), and
33        `content_type` is the MIME type of the content. For Genshi, return a
34        (template_name, data, content_type) tuple, where `data` is a dictionary
35        of substitutions for the template.
36
37        For both templating systems, "text/html" is assumed if `content_type` is
38        `None`.
39
40        Note that if template processing should not occur, this method can
41        simply send the response itself and not return anything.
42        """
43        foobar = FooBarTest(self.env)
44        req.send(foobar.foobar(), "text/plain")
45
46
47    ### methods for IRequireComponents
48
49    def requires(self):
50        return [ FooBarTest ]
Note: See TracBrowser for help on using the repository browser.