GetTogether/get_together/tests/teams.py
Briar Rose Schreiber 2951309f9c Issue 65: Team About Page
Addresses #65

* Added a team about page.
* The page is rendered at /<team_slug>/about/.
* If the about_page field is None, then the user is redirected to the team
  page.
* A link was added from the team page to view the about page
* A link on the about page was added to return to the team page
* Tests of redirect functionality were added
2018-07-01 15:53:56 -07:00

54 lines
1.4 KiB
Python

from django.test import TestCase, Client
from django.shortcuts import resolve_url
from django.utils import timezone
from django.urls import reverse
from model_mommy import mommy
import mock
import datetime
from django.contrib.auth.models import User
from events.ipstack import get_ipstack_geocoder
from events.models import Team
# Create your tests here.
class TeamDisplayTests(TestCase):
def setUp(self):
super().setUp()
def tearDown(self):
super().tearDown()
def test_show_team(self):
team = mommy.make(Team)
team.save()
team_url = team.get_absolute_url()
c = Client()
response = c.get(team_url)
assert(response.status_code == 200)
def test_show_about_team(self):
team = mommy.make(Team)
team.about_page = "about this team!"
team.save()
team_about_url = reverse('show-team-about-by-slug', kwargs={'team_slug': team.slug})
c = Client()
response = c.get(team_about_url)
assert(response.status_code == 200)
def test_show_about_team_redirects_if_none(self):
team = mommy.make(Team)
team.about_page = ""
team.save()
team_about_url = reverse('show-team-about-by-slug', kwargs={'team_slug': team.slug})
c = Client()
response = c.get(team_about_url)
assert(response.status_code == 302)