def test_manager_can_see_subordinate_summary_url(visitor_slug, can_see, running_interval, client): user = UserFactory(with_manager=True) users = { 'user': user, 'manager': user.manager, 'other_user': UserFactory(), 'superuser': UserFactory(is_superuser=True) } client.force_login(user=users[visitor_slug]) response = client.get(user.get_absolute_url()) assert bool(response.context.get('summary_url')) == can_see
def test_shown_only_reviews_with_published_selfreview(running_interval, client): reviewer = UserFactory() review_with_approved_selfreview = ReviewFactory(interval=running_interval, reviewer=reviewer) review_with_draft_selfreview = ReviewFactory(interval=running_interval, reviewer=reviewer) # not shown published_review = ReviewFactory(interval=running_interval, reviewer=reviewer, published=True) hidden_review = ReviewFactory(interval=running_interval, reviewer=reviewer, hidden=True) SelfReviewFactory(user=published_review.target, interval=running_interval, published=True) SelfReviewFactory(user=hidden_review.target, interval=running_interval, published=True) SelfReviewFactory(user=review_with_approved_selfreview.target, interval=running_interval, published=True) SelfReviewFactory(user=review_with_draft_selfreview.target, interval=running_interval, draft=True) client.force_login(user=reviewer) response = client.get( reverse('reviews:add-reviews', kwargs={'interval': running_interval})) assert response.status_code == 200 assert list(response.context['current_reviews']) == [ review_with_approved_selfreview ] response = client.get(reviewer.get_absolute_url(interval=running_interval)) assert response.status_code == 200 assert list(response.context['draft_reviews']) == [ review_with_approved_selfreview ]
def test_user_detail_reviews_context(running_interval, client): user = UserFactory(with_manager=True) draft = ReviewFactory(interval=running_interval, reviewer=user, draft=True) pending = ReviewFactory(interval=running_interval, reviewer=user, pending=True) approved = ReviewFactory(interval=running_interval, reviewer=user, hidden=True) rejected = ReviewFactory(interval=running_interval, reviewer=user, rejected=True) # make sure everyone has selfreview [ SelfReviewFactory(interval=running_interval, user=u, published=True) for u in User.objects.all() ] client.force_login(user=user) response = client.get(user.get_absolute_url()) assert list(response.context['draft_reviews']) == [draft] assert list(response.context['pending_reviews']) == [pending] assert list(response.context['approved_reviews']) == [approved] assert list(response.context['rejected_reviews']) == [rejected]
def test_get_absolute_url_inactive_user(running_interval): disabled_user = UserFactory(is_active=False) assert not disabled_user.get_absolute_url()