e6a659e686cca40af38d1e93a6163f26d1a59229
[hooke.git] / test / apply_command_stack.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 >>> import logging
21 >>> import sys
22 >>> from hooke.command_stack import CommandStack
23 >>> from hooke.engine import CommandMessage
24 >>> from hooke.hooke import Hooke
25 >>> h = Hooke()
26
27 Setup logging so we can check command output in the doctest.
28
29 >>> log = logging.getLogger('hooke')
30 >>> stdout_handler = logging.StreamHandler(sys.stdout)
31 >>> log.addHandler(stdout_handler)
32
33 Setup a playlist to act on.
34
35 >>> h.run_command('load playlist',
36 ...     {'input': 'test/data/vclamp_picoforce/playlist'})  # doctest: +ELLIPSIS
37 engine running internal <CommandMessage load playlist {input: test/data/vclamp_picoforce/playlist}>
38 engine message from load playlist (<class 'hooke.playlist.FilePlaylist'>): <FilePlaylist ...>
39 engine message from load playlist (<class 'hooke.command.Success'>): 
40 >>> stack = CommandStack([
41 ...         CommandMessage('get curve'),
42 ...         CommandMessage('zero surface contact point'),
43 ...         ])
44
45 Test `apply command stack`.
46
47 >>> h.run_command('apply command stack',
48 ...     {'commands': stack, 'evaluate': True})  # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
49 engine running internal <CommandMessage apply command stack
50   {commands: [<CommandMessage get curve>,
51               <CommandMessage zero surface contact point>],
52    evaluate: True}>
53 loading curve 20071120a_i27_t33.100 with driver ...
54 engine running internal <CommandMessage get curve>
55 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.100>
56 engine message from get curve (<class 'hooke.command.Success'>): 
57 engine running internal <CommandMessage zero surface contact point>
58 engine message from zero surface contact point (<type 'dict'>): {...}
59 engine message from zero surface contact point (<class 'hooke.command.Success'>): 
60 loading curve 20071120a_i27_t33.101 with driver ...
61 engine running internal <CommandMessage get curve>
62 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.101>
63 engine message from get curve (<class 'hooke.command.Success'>): 
64 engine running internal <CommandMessage zero surface contact point>
65 engine message from zero surface contact point (<type 'dict'>): {...}
66 engine message from zero surface contact point (<class 'hooke.command.Success'>): 
67 loading curve 20071120a_i27_t33.102 with driver ...
68 ...
69 loading curve 20071120a_i27_t33.199 with driver ...
70 engine running internal <CommandMessage get curve>
71 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.199>
72 engine message from get curve (<class 'hooke.command.Success'>): 
73 engine running internal <CommandMessage zero surface contact point>
74 engine message from zero surface contact point (<type 'dict'>): {...}
75 engine message from zero surface contact point (<class 'hooke.command.Success'>): 
76 loading curve 0x06130001 with driver ...
77 unloading curve 20071120a_i27_t33.100
78 engine running internal <CommandMessage get curve>
79 ...
80 engine message from apply command stack (<class 'hooke.command.Success'>): 
81 """