from rest_framework import status
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase

from measure_mate.models import Team
from measure_mate.tests.factories import TeamFactory


class TeamAPITestCases(APITestCase):
    def test_list_team(self):
        """
        List all teams and check that all fields are returned
        """
        team = TeamFactory()
        team2 = TeamFactory()

        url = reverse('team-list')
        response = self.client.get(url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), Team.objects.count())
        self.assertEqual(response.data[0]['id'], team.id)
        self.assertEqual(response.data[0]['name'], team.name)


@@ -115,16 +115,40 @@
 stCase%0A%0A
+import dateutil.parser%0A%0A
 from mea
@@ -228,16 +228,28 @@
 mFactory
+, TagFactory
 %0A%0A%0Aclass
@@ -723,16 +723,16 @@
 eam.id)%0A
-
         
@@ -785,9 +785,1608 @@
 m.name)%0A
+        self.assertEqual(response.data%5B0%5D%5B'short_desc'%5D, team.short_desc)%0A        self.assertEqual(dateutil.parser.parse(response.data%5B0%5D%5B'created'%5D), team.created)%0A        self.assertEqual(dateutil.parser.parse(response.data%5B0%5D%5B'updated'%5D), team.updated)%0A%0A    def test_create_team(self):%0A        %22%22%22%0A        Ensure we can create a new team object.%0A        %22%22%22%0A        tag = TagFactory()%0A%0A        url = reverse('team-list')%0A        data = %7B%22name%22: %22Test Team%22, %22short_desc%22: %22A team for testing with%22, %22tags%22: %5Btag.id%5D%7D%0A        response = self.client.post(url, data, format='json')%0A        self.assertEqual(response.status_code, status.HTTP_201_CREATED)%0A        self.assertEqual(Team.objects.count(), 1)%0A%0A    def test_fail_create_team(self):%0A        %22%22%22%0A        Ensure that missing name returns a 400.%0A        %22%22%22%0A        tag = TagFactory()%0A%0A        url = reverse('team-list')%0A        data = %7B%22short_desc%22: %22A team for testing with%22, %22tags%22: %5Btag.id%5D%7D%0A        response = self.client.post(url, data, format='json')%0A        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)%0A        self.assertEqual(Team.objects.count(), 0)%0A%0A    def test_fail_create_team_no_tag(self):%0A        %22%22%22%0A        Ensure that request fails when no tag is specified.%0A        %22%22%22%0A        tag = TagFactory()%0A%0A        url = reverse('team-list')%0A        data = %7B%22name%22: %22Test Team%22, %22short_desc%22: %22A team for testing with%22%7D%0A        response = self.client.post(url, data, format='json')%0A        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)%0A        self.assertEqual(Team.objects.count(), 0)%0A%0A
 %0A

add a few more team tests