示例#1
0
def test_find_one_context():
    repo = get_repo(mock_ui(), 'two_revs')

    opts = get_initial_opts()
    contexts = find_contexts(repo, repo[0], repo[1], opts)

    eq_(1, len(contexts))
def test_no_parent_combo():
    "You cannot have more than one parent revision."
    
    opts = get_initial_opts()
    opts['parent'] = 1
    opts['outgoingchanges'] = True
    postreview(mock_ui(), None, **opts)
示例#3
0
    def test_no_reviewboard_configured(self, mock_create_review):
        ui = mock_ui()
        ui.setconfig('reviewboard', 'server', None)

        repo = get_repo(ui, 'two_revs')
        opts = get_initial_opts()
        postreview(ui, repo, **opts)
示例#4
0
def test_find_server_from_command_line():
    ui = mock_ui()
    opts = get_initial_opts()
    opts['server'] = 'http://example.org'

    server = find_server(ui, opts)
    eq_('http://example.org', server)
示例#5
0
def test_find_two_contexts():
    repo = get_repo(mock_ui(), 'two_revs')

    opts = get_initial_opts()
    contexts = find_contexts(repo, repo['000000'], repo[1], opts)

    eq_(2, len(contexts))
示例#6
0
def test_find_server_from_command_line_no_hgrc():
    ui = mock_ui()
    ui.setconfig('reviewboard', 'server', None)
    opts = get_initial_opts()
    opts['server'] = 'http://example.org'

    server = find_server(ui, opts)
    eq_('http://example.org', server)
def set_up_two_revs():
    ui = mock_ui()
    repo = get_repo(ui, 'two_revs')
    opts = get_initial_opts()

    c = repo[1]
    parentc = repo['000000']

    return ui, repo, c, parentc, opts
示例#8
0
    def test_browser_launch_default(self, mock_launch, mock_create_method):
        ui = mock_ui()

        repo = get_repo(ui, 'two_revs')
        opts = get_initial_opts()
        opts['outgoingchanges'] = False
        opts['outgoing'] = False
        postreview(ui, repo, **opts)
        assert mock_launch.called == False
示例#9
0
def test_repo_id_autodetect():
    opts = get_initial_opts()
    opts['outgoingrepo'] = 'http://b.example.org'
    
    mock_reviewboard = Mock()
    repositories = [Repository(1, 'a', 'Mercurial', 'http://a.example.org'), 
        Repository(2, 'b', 'Mercurial', 'http://b.example.org')]
    mock_reviewboard.repositories.return_value = repositories
    
    eq_('2', find_reviewboard_repo_id(mock_ui(), mock_reviewboard, opts))
示例#10
0
def test_outgoing(mock_send):
    ui = mock_ui()
    repo = get_repo(ui, 'two_revs')
    opts = get_initial_opts()
    opts['outgoingchanges'] = False
    opts['outgoing'] = False
    postreview(ui, repo, **opts)

    expected = open('mercurial_reviewboard/tests/diffs/two_revs_1', 'r').read()
    eq_(expected, mock_send.call_args[0][4])
示例#11
0
    def test_browser_launch_false(self, mock_launch, mock_create_method):
        ui = mock_ui()
        ui.setconfig('reviewboard', 'launch_webbrowser', 'false')

        repo = get_repo(ui, 'two_revs')
        opts = get_initial_opts()
        opts['outgoingchanges'] = False
        opts['outgoing'] = False
        postreview(ui, repo, **opts)
        assert mock_launch.called == False
示例#12
0
def test_not_tip(mock_send):
    '''Test that the diff is for revision 0.'''
    ui = mock_ui()
    repo = get_repo(ui, 'two_revs_clone_not_tip')
    opts = get_initial_opts()
    opts['outgoingchanges'] = False
    opts['outgoing'] = False
    postreview(ui, repo, **opts)

    expected = open('mercurial_reviewboard/tests/diffs/two_revs_0', 'r').read()
    eq_(expected, mock_send.call_args[0][4])
示例#13
0
    def test_changeset_shown(self, mock_create_method):
        ui = mock_ui()

        repo = get_repo(ui, 'two_revs')
        opts = get_initial_opts()
        opts['parent'] = '000000'
        opts['outgoingchanges'] = False
        opts['outgoing'] = False
        postreview(ui, repo, **opts)

        eq_(self.expected_status, ui.status.call_args_list[1][0][0])
示例#14
0
    def test_reviewboard_option(self, mock_create_review):
        ui = mock_ui()
        ui.setconfig('reviewboard', 'server', None)

        repo = get_repo(ui, 'two_revs')
        opts = get_initial_opts()
        opts['server'] = 'example.com'
        opts['outgoingchanges'] = False
        opts['outgoing'] = False
        postreview(ui, repo, **opts)
        assert mock_create_review.called
示例#15
0
    def test_browser_launch_true(self, mock_launch, mock_create_method):
        mock_create_method.return_value = '1'

        ui = mock_ui()
        ui.setconfig('reviewboard', 'launch_webbrowser', 'true')

        repo = get_repo(ui, 'two_revs')
        opts = get_initial_opts()
        opts['outgoingchanges'] = False
        opts['outgoing'] = False
        postreview(ui, repo, **opts)
        eq_('http://example.com/r/1/', mock_launch.call_args[0][1])
示例#16
0
def test_get_credentials_from_config(mock_reviewboard):
        
    # username and password configs are included 
    # in the mock
    ui = mock_ui()
    opts = get_initial_opts()
        
    getreviewboard(ui, opts)
    
    mock_reviewboard.assert_called_with('http://example.com', 
        'foo', 'bar', proxy=None, apiver='')

    
def test_branch_description():
    ui = mock_ui()
    repo = get_repo(ui, 'branch')
    opts = get_initial_opts()
    opts['branch'] = True

    c = repo[4]
    parentc = repo[0]

    fields = createfields(ui, repo, c, parentc, opts)

    expected = ('review of branch: the_branch\n\n'
                'changesets:\n'
                '\t4:173fa0623445 "4"\n'
                '\t3:0c15fa2e6ba5 "3"\n')

    eq_(expected, fields['description'])
示例#18
0
    def test_changeset_on_branch(self, mock_create_method):
        """in branch mode only show revisions on branch"""
        expected_status = \
            'review of branch: default\n\n'\
            'changesets:\n\t5:1de20dbad49b "5"'\
            '\n\t2:e97ab41d91c8 "2"'\
            '\n\t1:7051d9f99104 "1"\n\t0:1d4da73b2570 "0"\n\n'

        ui = mock_ui()

        repo = get_repo(ui, 'merge')
        opts = get_initial_opts()
        opts['branch'] = True
        opts['outgoingchanges'] = False
        opts['outgoing'] = False
        postreview(ui, repo, **opts)

        eq_(expected_status, ui.status.call_args_list[1][0][0])
示例#19
0
    def test_changeset_shown(self, mock_create_method):
        """status should show all revisions on all included branches"""
        expected_status = \
            'changesets:\n\t5:1de20dbad49b "5"'\
            '\n\t4:d955e65420c8 "4"\n\t3:13a89135f389 "3"'\
            '\n\t2:e97ab41d91c8 "2"'\
            '\n\t1:7051d9f99104 "1"\n\t0:1d4da73b2570 "0"\n\n'

        ui = mock_ui()

        repo = get_repo(ui, 'merge')
        opts = get_initial_opts()
        opts['parent'] = '000000'
        opts['outgoingchanges'] = False
        opts['outgoing'] = False
        postreview(ui, repo, **opts)

        eq_(expected_status, ui.status.call_args_list[1][0][0])
示例#20
0
def test_repo_id_from_opts():
    opts = get_initial_opts()
    opts['repoid'] = '101'
    eq_('101', find_reviewboard_repo_id(None, None, opts))    
示例#21
0
def test_find_server_from_hgrc():
    ui = mock_ui()
    opts = get_initial_opts()

    server = find_server(ui, opts)
    eq_('http://example.com', server)
示例#22
0
def test_find_server_not_defined():
    ui = mock_ui()
    ui.setconfig('reviewboard', 'server', None)
    opts = get_initial_opts()

    find_server(ui, opts)