Esempio n. 1
0
    def test_it_includes_search_url_when_on_user_search(self, req):
        type(req.matched_route).name = PropertyMock(
            return_value='activity.user_search')
        req.matchdict = {'username': '******'}

        result = panels.navbar({}, req)
        assert result['search_url'] == 'http://example.com/users/luke/search'
Esempio n. 2
0
def test_navbar_username_link_when_logged_in(pyramid_request,
                                             authenticated_user):
    pyramid_request.authenticated_user = authenticated_user
    result = panels.navbar({}, pyramid_request)

    assert result[
        'username_link'] == 'http://example.com/search?q=user:vannevar'
Esempio n. 3
0
    def test_it_includes_search_url_when_on_group_search(self, req):
        type(req.matched_route).name = PropertyMock(
            return_value='activity.group_search')
        req.matchdict = {'pubid': 'foobar'}

        result = panels.navbar({}, req)
        assert result[
            'search_url'] == 'http://example.com/groups/foobar/search'
Esempio n. 4
0
    def test_it_lists_groups_when_logged_in(self, req, authenticated_user):
        req.authenticated_user = authenticated_user
        result = panels.navbar({}, req)

        titles = [group.name for group in authenticated_user.groups]

        assert result['groups_menu_items'] == [
            {'title': titles[0], 'link': 'http://example.com/groups/id1/first'},
            {'title': titles[1], 'link': 'http://example.com/groups/id2/second'},
        ]
Esempio n. 5
0
def test_navbar_lists_groups_when_logged_in(pyramid_request, authenticated_user):
    pyramid_request.authenticated_user = authenticated_user
    result = panels.navbar({}, pyramid_request)

    titles = [group.name for group in authenticated_user.groups]

    assert result["groups_menu_items"] == [
        {"title": titles[0], "link": "http://example.com/groups/id1/first"},
        {"title": titles[1], "link": "http://example.com/groups/id2/second"},
    ]
Esempio n. 6
0
    def test_it_lists_groups_when_logged_in(self, req, authenticated_user):
        req.authenticated_user = authenticated_user
        result = panels.navbar({}, req)

        titles = [group.name for group in authenticated_user.groups]

        assert result['groups_menu_items'] == [
            {'title': titles[0], 'link': 'http://example.com/groups/id1/first'},
            {'title': titles[1], 'link': 'http://example.com/groups/id2/second'},
        ]
Esempio n. 7
0
 def test_it_sets_null_username_when_logged_out(self, req):
     result = panels.navbar({}, req)
     assert result['username'] is None
Esempio n. 8
0
    def test_it_sets_username_when_logged_in(self, req, authenticated_user):
        req.authenticated_user = authenticated_user
        result = panels.navbar({}, req)

        assert result['username'] == 'vannevar'
Esempio n. 9
0
    def test_it_includes_search_query(self, req):
        req.params['q'] = 'tag:question'
        result = panels.navbar({}, req)

        assert result['q'] == 'tag:question'
Esempio n. 10
0
    def test_username_url_when_logged_in(self, req, authenticated_user):
        req.authenticated_user = authenticated_user
        result = panels.navbar({}, req)

        assert result[
            'username_url'] == 'http://example.com/users/vannevar/search'
Esempio n. 11
0
    def test_it_sets_username_when_logged_in(self, req, authenticated_user):
        req.authenticated_user = authenticated_user
        result = panels.navbar({}, req)

        assert result['username'] == 'vannevar'
Esempio n. 12
0
    def test_it_includes_search_query(self, req):
        req.params['q'] = 'tag:question'
        result = panels.navbar({}, req)

        assert result['q'] == 'tag:question'
Esempio n. 13
0
def test_navbar_sets_username_when_logged_in(pyramid_request,
                                             authenticated_user):
    pyramid_request.authenticated_user = authenticated_user
    result = panels.navbar({}, pyramid_request)

    assert result['username'] == 'vannevar'
Esempio n. 14
0
def test_navbar_username_link_when_logged_in(pyramid_request, authenticated_user):
    pyramid_request.authenticated_user = authenticated_user
    result = panels.navbar({}, pyramid_request)

    assert result["username_link"] == "http://example.com/search?q=user:vannevar"
Esempio n. 15
0
    def test_username_link_when_logged_in(self, req, authenticated_user):
        req.authenticated_user = authenticated_user
        result = panels.navbar({}, req)

        assert result['username_link'] == 'http://example.com/search?q=user:vannevar'
Esempio n. 16
0
def test_navbar_sets_username_when_logged_in(pyramid_request, authenticated_user):
    pyramid_request.authenticated_user = authenticated_user
    result = panels.navbar({}, pyramid_request)

    assert result["username"] == "vannevar"
Esempio n. 17
0
def test_navbar_sets_null_username_when_logged_out(pyramid_request):
    pyramid_request.authenticated_user = None
    result = panels.navbar({}, pyramid_request)
    assert result["username"] == None
Esempio n. 18
0
 def test_it_includes_default_search_url(self, req):
     result = panels.navbar({}, req)
     assert result['search_url'] == 'http://example.com/search'
Esempio n. 19
0
    def test_it_includes_search_url_when_on_group_search(self, req):
        type(req.matched_route).name = PropertyMock(return_value='activity.group_search')
        req.matchdict = {'pubid': 'foobar'}

        result = panels.navbar({}, req)
        assert result['search_url'] == 'http://example.com/groups/foobar/search'
Esempio n. 20
0
    def test_it_includes_search_url_when_on_user_search(self, req):
        type(req.matched_route).name = PropertyMock(return_value='activity.user_search')
        req.matchdict = {'username': '******'}

        result = panels.navbar({}, req)
        assert result['search_url'] == 'http://example.com/users/luke/search'
Esempio n. 21
0
 def test_it_includes_default_search_url(self, req):
     result = panels.navbar({}, req)
     assert result['search_url'] == 'http://example.com/search'
Esempio n. 22
0
def test_navbar_sets_null_username_when_logged_out(pyramid_request):
    pyramid_request.authenticated_user = None
    result = panels.navbar({}, pyramid_request)
    assert result['username'] == None
Esempio n. 23
0
def test_navbar_includes_search_query(pyramid_request):
    pyramid_request.authenticated_user = None
    pyramid_request.params["q"] = "tag:question"
    result = panels.navbar({}, pyramid_request)

    assert result["q"] == "tag:question"
Esempio n. 24
0
 def test_it_sets_null_username_when_logged_out(self, req):
     result = panels.navbar({}, req)
     assert result['username'] is None
Esempio n. 25
0
    def test_username_url_when_logged_in(self, req, authenticated_user):
        req.authenticated_user = authenticated_user
        result = panels.navbar({}, req)

        assert result['username_url'] == 'http://example.com/users/vannevar/search'