Merge pull request #22 from LewisHaley/minor-fix

minor fix: reference to `noise_threshold` changed to `confirm_threshold`
Configuration in tool-specific sections no longer overrides "global" section

This affects the loading of default values from the configuration file
for "stbt run" and "stbt record", and the behaviour of the python
function "stbt.get_config" and of the command-line utility
"stbt config".

Note that configuration items that are only used by a single tool still
remain in the tool-specific section. Those items now must be in the
tool-specific section; they won't be searched for in the "global"
section.

UPGRADING
=========

This is a non-backwards-compatible change. If you had customised your
config file, you will need to ensure it complies with the new expected
layout:

* Move these entries from the "[run]" or "[record]" sections to the
  "[global]" section:

  - control
  - source_pipeline
  - sink_pipeline
  - verbose

* This entry must be in the "[run]" section:

  - script

* These entries must be in the "[record]" section:

  - output_file
  - control_recorder

BACKGROUND
==========

The tools like "stbt run" and "stbt record" take parameters on the
command line, like "--source-pipeline". If not specified on the command
line, the value is taken from the configuration file(s). In a typical
installation, the following files are searched:

* /etc/stbt/stbt.conf
* ~/.config/stbt/stbt.conf
* $STBT_CONFIG_FILE

(with later files taking precedence).

These files use the "ini" format:

    [section]
    key = value

Prior to this commit, "stbt run" searches for each configuration item
(e.g. "source_pipeline") in the "[run]" section; if not found, then it
searches in the "[global]" section.

The confusing behaviour was that "[run] source_pipeline" specified in
/etc/stbt/stbt.conf would override "[global] source_pipeline" specified
in ~/.config/stbt/stbt.conf (note that if both items were specified in
the same section, the precedence would be the opposite order).

Nobody actually uses this "feature" -- there hasn't been a need for a
particular tool to override the global configuration used by all other
tools.
test_get_config: Test all possible failures

Previously, the line `stbt.get_config("no_such_key")` would fail
(as expected) and jump to the `except` block; so the other two
`stbt.get_config` lines weren't tested at all.

This also catches `ConfigurationError` explicitly (instead of all
exceptions) to test that `stbt.get_config` is throwing the correct
exception type.
stbt.get_config: Cleanup: Remove `load_config` helper function
stbt.get_config: Handle all ConfigParser errors

...and use ConfigParser's own error messages:

* No option 'no_such_key' in section: 'global'
* No section: 'no_such_section'
etc.

Note that ConfigParser supports interpolation, so values can refer to
other values, e.g.

    [My Section]
    foodir: %(dir)s/whatever
    dir=frob

so there are many possible ConfigParser exception types other than
NoSectionError and NoOptionError.
stbt.py: `mock_get_config` returns same types as real `get_config`

(in `test_build_templatematch_params_detects_undefined`).

This doesn't really affect the test; it's just for consistency with
the real `get_config`.
Merge branch 'config-sections'

The important functional change is 9283df1 (Configuration in
tool-specific sections no longer overrides "global" section).

* config-sections:
  stbt.py: `mock_get_config` returns same types as real `get_config`
  stbt.get_config: Handle all ConfigParser errors
  stbt.get_config: Cleanup: Remove `load_config` helper function
  test_get_config: Test all possible failures
  Configuration in tool-specific sections no longer overrides "global" section