def test_nrfjprog_create(build_conf, check_call, get_snr, require, test_case,
                         runner_config, tmpdir):
    runner_config = fix_up_runner_config(test_case, runner_config, tmpdir)
    build_conf.return_value = build_configuration(test_case)
    expected = EXPECTED_RESULTS[test_case]

    args = []
    if test_case.softreset:
        args.append('--softreset')
    if test_case.snr:
        args.extend(['--snr', TEST_OVR_SNR])
    if test_case.erase:
        args.append('--erase')
    if test_case.recover:
        args.append('--recover')

    parser = argparse.ArgumentParser()
    NrfJprogBinaryRunner.add_parser(parser)
    arg_namespace = parser.parse_args(args)
    runner = NrfJprogBinaryRunner.create(runner_config, arg_namespace)
    with patch('os.path.isfile', side_effect=os_path_isfile_patch):
        runner.run('flash')

    assert require.called
    if callable(expected):
        assert (check_call.call_args_list ==
                [call(x) for x in expected(tmpdir, runner_config.hex_file)])
    else:
        assert check_call.call_args_list == [call(x) for x in expected]

    if not test_case.snr:
        get_snr.assert_called_once_with('*')
    else:
        get_snr.assert_not_called()
def test_nrfjprog_init(build_conf, check_call, get_snr, require, test_case,
                       runner_config, tmpdir):
    runner_config = fix_up_runner_config(test_case, runner_config, tmpdir)
    build_conf.return_value = build_configuration(test_case)
    expected = EXPECTED_RESULTS[test_case]
    snr = TEST_OVR_SNR if test_case.snr else None
    runner = NrfJprogBinaryRunner(runner_config,
                                  test_case.family,
                                  test_case.softreset,
                                  snr,
                                  erase=test_case.erase,
                                  recover=test_case.recover)

    with patch('os.path.isfile', side_effect=os_path_isfile_patch):
        runner.run('flash')
    assert require.called

    if callable(expected):
        assert (check_call.call_args_list ==
                [call(x) for x in expected(tmpdir, runner_config.hex_file)])
    else:
        assert check_call.call_args_list == [call(x) for x in expected]

    if snr is None:
        get_snr.assert_called_once_with('*')
    else:
        get_snr.assert_not_called()
Пример #3
0
def test_nrfjprog_create(cc, get_snr, req, test_case, runner_config):
    family, softreset, snr, erase = test_case

    args = ['--nrf-family', family]
    if softreset:
        args.append('--softreset')
    if snr is not None:
        args.extend(['--snr', snr])
    if erase:
        args.append('--erase')

    parser = argparse.ArgumentParser()
    NrfJprogBinaryRunner.add_parser(parser)
    arg_namespace = parser.parse_args(args)
    runner = NrfJprogBinaryRunner.create(runner_config, arg_namespace)
    with patch('os.path.isfile', side_effect=os_path_isfile_patch):
        runner.run('flash')

    assert req.called
    assert cc.call_args_list == [
        call(x) for x in expected_commands(*test_case)
    ]
    if snr is None:
        get_snr.assert_called_once_with()
    else:
        get_snr.assert_not_called()
Пример #4
0
def test_nrfjprog_init(cc, get_snr, test_case, runner_config):
    family, softreset, snr, erase = test_case

    runner = NrfJprogBinaryRunner(runner_config, family, softreset, snr,
                                  erase=erase)
    runner.run('flash')

    assert cc.call_args_list == [call(x) for x in
                                 expected_commands(*test_case)]
    if snr is None:
        get_snr.assert_called_once_with()
    else:
        get_snr.assert_not_called()
Пример #5
0
def test_nrfjprog_init(cc, get_snr, req, test_case, runner_config):
    family, softreset, snr, erase = test_case

    runner = NrfJprogBinaryRunner(runner_config, family, softreset, snr,
                                  erase=erase)
    with patch('os.path.isfile', side_effect=os_path_isfile_patch):
        runner.run('flash')
    assert req.called
    assert cc.call_args_list == [call(x) for x in
                                 expected_commands(*test_case)]

    if snr is None:
        get_snr.assert_called_once_with('*')
    else:
        get_snr.assert_called_once_with(snr)
Пример #6
0
def test_nrfjprog_init(cc, get_snr, req, test_case, runner_config):
    family, softreset, snr, erase = test_case

    runner = NrfJprogBinaryRunner(runner_config, family, softreset, snr,
                                  erase=erase)
    if snr is None:
        with pytest.raises(ValueError) as e:
            runner.run('flash')
        assert 'snr must not be None' in str(e.value)
    else:
        runner.run('flash')
        assert req.called
        assert cc.call_args_list == [call(x) for x in
                                     expected_commands(*test_case)]
        get_snr.assert_not_called()