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 = navbar({}, req) assert result["search_url"] == "http://example.com/users/luke"
def test_includes_groups_suggestions_when_logged_in(self, req, user, open_group): req.user = user result = navbar({}, req) assert result['groups_suggestions'] == [{'name': g.name, 'pubid': g.pubid, 'relationship': 'Creator' if g.creator == user else None} for g in user.groups]
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 = navbar({}, req) assert result['search_url'] == 'http://example.com/users/luke'
def test_it_includes_search_url_when_on_group_search(self, req): type(req.matched_route).name = PropertyMock(return_value='group_read') req.matchdict = {'pubid': 'foobar', 'slug': 'slugbar'} result = navbar({}, req) assert result[ 'search_url'] == 'http://example.com/groups/foobar/slugbar'
def test_it_includes_search_url_when_on_group_search(self, req): type(req.matched_route).name = PropertyMock(return_value="group_read") req.matchdict = {"pubid": "foobar", "slug": "slugbar"} result = navbar({}, req) assert result[ "search_url"] == "http://example.com/groups/foobar/slugbar"
def test_includes_groups_suggestions_when_logged_in( self, req, user, open_group): req.user = user result = navbar({}, req) assert result['groups_suggestions'] == [{ 'name': g.name, 'pubid': g.pubid } for g in user.groups]
def test_it_lists_groups_when_logged_in(self, req, user): req.user = user result = navbar({}, req) assert result['groups_menu_items'] == [ {'title': g.name, 'link': 'http://example.com/groups/' + g.pubid + '/' + g.slug} for g in user.groups ]
def test_it_lists_groups_when_logged_in(self, req, authenticated_user): req.authenticated_user = authenticated_user result = navbar({}, req) assert result["groups_menu_items"] == [ {"title": g.name, "link": "http://example.com/groups/" + g.pubid + "/" + g.slug} for g in authenticated_user.groups ]
def test_includes_groups_suggestions_when_logged_in( self, req, authenticated_user): req.authenticated_user = authenticated_user result = navbar({}, req) assert result['groups_suggestions'] == [{ 'name': g.name, 'pubid': g.pubid } for g in authenticated_user.groups]
def test_it_lists_groups_when_logged_in(self, req, user): req.user = user result = navbar({}, req) assert result["groups_menu_items"] == [{ "title": g.name, "link": "http://example.com/groups/" + g.pubid + "/" + g.slug, } for g in user.groups]
def test_includes_groups_suggestions_when_logged_in(self, req, user, open_group): req.user = user result = navbar({}, req) assert result["groups_suggestions"] == [ { "name": g.name, "pubid": g.pubid, "relationship": "Creator" if g.creator == user else None, } for g in user.groups ]
def test_it_sets_null_username_when_logged_out(self, req): result = navbar({}, req) assert result["username"] is None
def test_username_url_when_logged_in(self, req, authenticated_user): req.authenticated_user = authenticated_user result = navbar({}, req) assert result['username_url'] == 'http://example.com/users/vannevar'
def test_includes_groups_suggestions_when_logged_in(self, req, user): req.user = user result = navbar({}, req) assert result['groups_suggestions'] == [{'name': g.name, 'pubid': g.pubid} for g in user.groups]
def test_it_includes_search_query(self, req): req.params['q'] = 'tag:question' result = navbar({}, req) assert result['q'] == 'tag:question'
def test_it_includes_default_search_url(self, req): result = navbar({}, req) assert result["search_url"] == "http://example.com/search"
def test_it_includes_search_url_when_on_group_search(self, req): type(req.matched_route).name = PropertyMock(return_value="group_read") req.matchdict = {"pubid": "foobar", "slug": "slugbar"} result = navbar({}, req) assert result["search_url"] == "http://example.com/groups/foobar/slugbar"
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 = navbar({}, req) assert result['search_url'] == 'http://example.com/users/luke'
def test_it_includes_search_url_when_on_group_search(self, req): type(req.matched_route).name = PropertyMock(return_value='group_read') req.matchdict = {'pubid': 'foobar', 'slug': 'slugbar'} result = navbar({}, req) assert result['search_url'] == 'http://example.com/groups/foobar/slugbar'
def test_username_url_when_logged_in(self, req, user): req.user = user result = navbar({}, req) assert result["username_url"] == "http://example.com/users/vannevar"
def test_it_sets_username_when_logged_in(self, req, user): req.user = user result = navbar({}, req) assert result["username"] == "vannevar"
def test_it_includes_default_search_url_if_no_matched_route(self, req): req.matched_route = None result = navbar({}, req) assert result["search_url"] == "http://example.com/search"
def test_includes_groups_suggestions_when_logged_in(self, req, authenticated_user): req.authenticated_user = authenticated_user result = navbar({}, req) assert result["groups_suggestions"] == [{"name": g.name, "pubid": g.pubid} for g in authenticated_user.groups]
def test_it_includes_search_query(self, req): req.params["q"] = "tag:question" result = navbar({}, req) assert result["q"] == "tag:question"
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 = navbar({}, req) assert result["search_url"] == "http://example.com/users/luke"
def test_it_sets_username_when_logged_in(self, req, authenticated_user): req.authenticated_user = authenticated_user result = navbar({}, req) assert result['username'] == 'vannevar'