genpkg_help_information_steps.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Copyright (c) 2015, Nordic Semiconductor
  2. # All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. #
  7. # * Redistributions of source code must retain the above copyright notice, this
  8. # list of conditions and the following disclaimer.
  9. #
  10. # * Redistributions in binary form must reproduce the above copyright notice,
  11. # this list of conditions and the following disclaimer in the documentation
  12. # and/or other materials provided with the distribution.
  13. #
  14. # * Neither the name of Nordic Semiconductor ASA nor the names of its
  15. # contributors may be used to endorse or promote products derived from
  16. # this software without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  22. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  24. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  25. # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. from Queue import Empty
  29. import logging
  30. import os
  31. import time
  32. import sys
  33. from click.testing import CliRunner
  34. from behave import then, given, when
  35. from nordicsemi.__main__ import cli, int_as_text_to_int
  36. logger = logging.getLogger(__file__)
  37. STDOUT_TEXT_WAIT_TIME = 50 # Number of seconds to wait for expected output from stdout
  38. @given(u'user types \'{command}\'')
  39. def step_impl(context, command):
  40. args = command.split(' ')
  41. assert args[0] == 'nrfutil'
  42. exec_args = args[1:]
  43. runner = CliRunner()
  44. context.runner = runner
  45. context.args = exec_args
  46. @then(u'output contains \'{stdout_text}\' and exit code is {exit_code}')
  47. def step_impl(context, stdout_text, exit_code):
  48. result = context.runner.invoke(cli, context.args)
  49. logger.debug("exit_code: %s, output: \'%s\'", result.exit_code, result.output)
  50. assert result.exit_code == int_as_text_to_int(exit_code)
  51. assert result.output != None
  52. assert result.output.find(stdout_text) >= 0