test/data/vclamp_jpk/README: Document sample versions
[hooke.git] / test / block_info.py
1 # Copyright (C) 2010-2012 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of Hooke.
4 #
5 # Hooke is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
8 # later version.
9 #
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
17
18 """
19 >>> import os
20 >>> from uuid import uuid4
21 >>> from hooke.hooke import Hooke, HookeRunner
22 >>> h = Hooke()
23 >>> r = HookeRunner()
24 >>> h = r.run_lines(h, ['load_playlist test/data/test']) # doctest: +ELLIPSIS
25 <FilePlaylist test.hkp>
26 Success
27 <BLANKLINE>
28
29 >>> file_name = '%s.block' % uuid4()
30 >>> block_info_already_exists = os.path.exists(file_name)
31 >>> block_info_already_exists
32 False
33 >>> h = r.run_lines(h, ['block_info --output %s name columns "raw info.Scanner list.Serial n*"'
34 ...                     % file_name]) # doctest: +ELLIPSIS, +REPORT_UDIFF
35 {'columns': ['z piezo (m)', 'deflection (m)'],
36  'index': 0,
37  'name': 'approach',
38  'raw info': {'Scanner list': {'Serial number': '196PF'}}}
39 Success
40 <BLANKLINE>
41 >>> with open(file_name, 'r') as f:
42 ...     text = f.read()
43 >>> if block_info_already_exists == False:
44 ...    os.remove(file_name)
45 >>> print(text)  # doctest: +ELLIPSIS, +REPORT_UDIFF
46 picoforce.000:
47   approach:
48     columns: [z piezo (m), deflection (m)]
49     index: 0
50     name: approach
51     raw info:
52       Scanner list: {Serial number: 196PF}
53   path: .../test/data/picoforce.000
54 <BLANKLINE>
55 """