Exemplo n.º 1
0
def test_action_update__invalid_id(capsys):
    rpc = mock.Mock()
    rpc.patch_get.return_value = {}

    with pytest.raises(SystemExit):
        patches.action_update(rpc, 1)

    captured = capsys.readouterr()

    assert captured.out == ''
    assert captured.err == 'Error getting information on patch ID 1\n'
Exemplo n.º 2
0
def test_action_update__no_updates(capsys):
    rpc = mock.Mock()
    rpc.patch_get.return_value = fakes.fake_patches()[0]
    rpc.patch_set.return_value = None

    patches.action_update(rpc, 1157169)

    rpc.patch_set.assert_called_once_with(1157169, {})

    captured = capsys.readouterr()

    assert captured.out == ''
    assert captured.err == 'Patch not updated\n'
Exemplo n.º 3
0
def test_action_update__error(capsys):
    rpc = mock.Mock()
    rpc.patch_get.return_value = fakes.fake_patches()[0]
    rpc.patch_set.side_effect = xmlrpc.xmlrpclib.Fault(1, 'x')

    patches.action_update(rpc, 1157169)

    rpc.patch_set.assert_called_once_with(1157169, {})

    captured = capsys.readouterr()

    assert captured.out == ''
    assert captured.err == """\
Exemplo n.º 4
0
def test_action_update(mock_get_state, capsys):
    rpc = mock.Mock()
    rpc.patch_get.return_value = fakes.fake_patches()[0]
    rpc.patch_set.return_value = True
    mock_get_state.return_value = 1

    patches.action_update(rpc, 1157169, 'Accepted', 'yes', '698fa7f')

    rpc.patch_set.assert_called_once_with(1157169, {
        'state': 1,
        'commit_ref': '698fa7f',
        'archived': True
    })
    mock_get_state.assert_called_once_with(rpc, 'Accepted')
Exemplo n.º 5
0
def test_action_update__invalid_state(mock_get_state, capsys):
    rpc = mock.Mock()
    rpc.patch_get.return_value = fakes.fake_patches()[0]
    rpc.patch_set.return_value = True
    mock_get_state.return_value = 0

    with pytest.raises(SystemExit):
        patches.action_update(rpc, 1157169, state='Accccccepted')

    mock_get_state.assert_called_once_with(rpc, 'Accccccepted')

    captured = capsys.readouterr()

    assert captured.out == ''
    assert captured.err == 'Error: No State found matching Accccccepted*\n'