Remove export and distance sections from test/tutorial.py (they duplicate other test...
[hooke.git] / test / tutorial.py
1 # Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
2 #
3 # This file is part of Hooke.
4 #
5 # Hooke is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
9 #
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
13 # Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke.  If not, see
17 # <http://www.gnu.org/licenses/>.
18
19 """
20 Test the commands listed in :file:`doc/tutorial.txt`.
21
22 >>> import os
23 >>> import os.path
24 >>> from hooke.hooke import Hooke, HookeRunner
25 >>> h = Hooke()
26 >>> r = HookeRunner()
27
28 *Help*
29
30 >>> h = r.run_lines(h, ['help'])  # doctest: +ELLIPSIS
31 <BLANKLINE>
32 Documented commands (type help <topic>):
33 ========================================
34 ...
35 >>> h = r.run_lines(h, ['help load_playlist'])
36 Command: load_playlist
37 <BLANKLINE>
38 Arguments:
39 <BLANKLINE>
40 help BOOL (bool) Print a help message.
41 output_playlist STRING (string) Name of the new playlist (defaults to
42     an auto-generated name).
43 input FILE (file) File name for the input playlist.
44 drivers DRIVER (driver) Drivers for loading curves.
45 <BLANKLINE>
46 Load a playlist.
47 <BLANKLINE>
48 ----
49 Usage: load_playlist [options] input
50
51 *Creating a playlist*
52
53 >>> h = r.run_lines(h, ['cd --path .'])
54 Success
55 <BLANKLINE>
56 >>> h = r.run_lines(h, ['pwd'])  # doctest: +ELLIPSIS
57 /.../hooke
58 Success
59 <BLANKLINE>
60 >>> h = r.run_lines(h, ['ls'])  # doctest: +ELLIPSIS +REPORT_UDIFF
61 .hg
62 ...
63 AUTHORS
64 ...
65 README
66 ...
67 hooke
68 ...
69 Success
70 <BLANKLINE>
71 >>> h = r.run_lines(h, ['new_playlist --output_playlist mylist'])
72 Success
73 <BLANKLINE>
74 >>> h = r.run_lines(h, ['jump_to_playlist -- -1'])
75 Success
76 <BLANKLINE>
77 >>> h = r.run_lines(h, ['get_playlist'])
78 <FilePlaylist mylist>
79 Success
80 <BLANKLINE>
81 >>> h = r.run_lines(h, ['glob_curves_to_playlist test/data/vclamp_picoforce/*']
82 ...     )  # doctest: +ELLIPSIS
83 <Curve 0x06130001>
84 <Curve 0x07200000>
85 <Curve 20071120a_i27_t33.100>
86 <Curve 20071120a_i27_t33.101>
87 ...
88 <Curve 20071120a_i27_t33.199>
89 Success
90 <BLANKLINE>
91 >>> playlist_already_exists = os.path.exists('mylist.hkp')
92 >>> playlist_already_exists
93 False
94 >>> h = r.run_lines(h, ['save_playlist --output mylist'])
95 Success
96 <BLANKLINE>
97 >>> os.path.isfile('mylist.hkp')
98 True
99 >>> h = r.run_lines(h, ['load_playlist mylist.hkp'])
100 <FilePlaylist mylist.hkp>
101 Success
102 <BLANKLINE>
103 >>> if playlist_already_exists == False:
104 ...     os.remove('mylist.hkp')
105
106 *Navigating the playlist*
107
108 >>> h = r.run_lines(h, ['get_curve'])
109 <Curve 0x06130001>
110 Success
111 <BLANKLINE>
112 >>> h = r.run_lines(h, ['next_curve'])
113 Success
114 <BLANKLINE>
115 >>> h = r.run_lines(h, ['get_curve'])
116 <Curve 0x07200000>
117 Success
118 <BLANKLINE>
119 >>> h = r.run_lines(h, ['previous_curve'])
120 Success
121 <BLANKLINE>
122 >>> h = r.run_lines(h, ['get_curve'])
123 <Curve 0x06130001>
124 Success
125 <BLANKLINE>
126 >>> h = r.run_lines(h, ['curve_index'])
127 0
128 Success
129 <BLANKLINE>
130 >>> h = r.run_lines(h, ['previous_curve'])
131 Success
132 <BLANKLINE>
133 >>> h = r.run_lines(h, ['get_curve'])
134 <Curve 20071120a_i27_t33.199>
135 Success
136 <BLANKLINE>
137 >>> h = r.run_lines(h, ['curve_index'])
138 101
139 Success
140 <BLANKLINE>
141 >>> h = r.run_lines(h, ['next_curve'])
142 Success
143 <BLANKLINE>
144 >>> h = r.run_lines(h, ['get_curve'])
145 <Curve 0x06130001>
146 Success
147 <BLANKLINE>
148 >>> h = r.run_lines(h, ['curve_index'])
149 0
150 Success
151 <BLANKLINE>
152 >>> h = r.run_lines(h, ['jump_to_curve 14'])
153 Success
154 <BLANKLINE>
155 >>> h = r.run_lines(h, ['get_curve'])
156 <Curve 20071120a_i27_t33.112>
157 Success
158 <BLANKLINE>
159 >>> h = r.run_lines(h, ['curve_index'])
160 14
161 Success
162 <BLANKLINE>
163
164 >>> h = r.run_lines(h, ['get_playlist'])
165 <FilePlaylist mylist>
166 Success
167 <BLANKLINE>
168 >>> h = r.run_lines(h, ['next_playlist'])
169 Success
170 <BLANKLINE>
171 >>> h = r.run_lines(h, ['get_playlist'])
172 <FilePlaylist mylist.hkp>
173 Success
174 <BLANKLINE>
175 >>> h = r.run_lines(h, ['previous_playlist'])
176 Success
177 <BLANKLINE>
178 >>> h = r.run_lines(h, ['get_playlist'])
179 <FilePlaylist mylist>
180 Success
181 <BLANKLINE>
182 >>> h = r.run_lines(h, ['playlist_index'])
183 0
184 Success
185 <BLANKLINE>
186 >>> h = r.run_lines(h, ['previous_playlist'])
187 Success
188 <BLANKLINE>
189 >>> h = r.run_lines(h, ['get_playlist'])
190 <FilePlaylist mylist.hkp>
191 Success
192 <BLANKLINE>
193 >>> h = r.run_lines(h, ['playlist_index'])
194 1
195 Success
196 <BLANKLINE>
197 >>> h = r.run_lines(h, ['next_playlist'])
198 Success
199 <BLANKLINE>
200 >>> h = r.run_lines(h, ['get_playlist'])
201 <FilePlaylist mylist>
202 Success
203 <BLANKLINE>
204 >>> h = r.run_lines(h, ['playlist_index'])
205 0
206 Success
207 <BLANKLINE>
208 >>> h = r.run_lines(h, ['jump_to_playlist 1'])
209 Success
210 <BLANKLINE>
211 >>> h = r.run_lines(h, ['get_playlist'])
212 <FilePlaylist mylist.hkp>
213 Success
214 <BLANKLINE>
215 >>> h = r.run_lines(h, ['playlist_index'])
216 1
217 Success
218 <BLANKLINE>
219
220 *Taking notes*
221
222 See :file:`note.py`.
223
224 *Exporting curves*
225
226 See :file:`export_block.py`.
227
228 *Measuring distances and forces*
229
230 See :file:`delta.py`.
231
232 *Worm like chain and freely jointed chain fitting*
233
234 *Multiple curve fitting and measuring*
235
236 *Fast curve reviewing and saving*
237
238 *Configuring Hooke*
239
240 See :file:`config.py`.
241 """