Share this Page URL

Chapter 43. Creating Functional Doc Test... > Creating and Running the Test - Pg. 288

Creating Functional Doc Tests 288 Now you simply start Zope 3. The rest of this chapter assumes that Zope runs on port 8080. Because you only want to test the rendering of the ZPT, you can add a new ZPT page called newzptpage via the Web GUI; it should have the following template code: 01 <html> 02 <body> 03 <h1 tal:content="modules/time/asctime" /> 04 </body> 05 </html> Setting Up TCPWatch As mentioned previously, you use TCPWatch to record a Web GUI session. You can find the TCPWatch script on Shane Hathaway's website, You should download the latest version. When the download is complete, you need to untar the archive: tar xvzf tcpwatch-1.x.tar.gz Next, you enter the newly created directory tcpwatch. You can then install the script by calling the following: python install You might have to be root to call this command because Python might be installed in a directory you do not have write access to. Now you need to create a temporary directory that TCPWatch can use to store the collected requests and responses: mkdir tmp Next, you start the script by using the following: /path/to/python/bin/ -L 8081:8080 -s -r tmp The -L option tells TCPWatch to listen on port 8081 for incoming connections, -s outputs the result to stdout instead of to a graphical window, and -r <dir> specifies the directory to record the session. After you start TCPWatch, you can access Zope also via port 8081, except that all communication between the client and the server is also reported by TCPWatch. Recording a Session When everything is set up according to the directions in the preceding section, you can do whatever you want via port 8081. Don't forget to log in as mgr on port 8081 so that the authentication will also work via the functional test. In this case, you just call the URL http://localhost:8081/new- zptpage, which renders the result, all of which is recorded, to the page output. When you are done recording, you need to shut down TCPWatch by pressing Ctrl+C. You might also want to shut down Zope 3. Creating and Running the Test After the session is recorded, you can convert it to a functional test by using the following: