@@ -0,0 +1,2307 @@
+import json%0A%0Afrom api.tests.test_api import TestAPICase%0A%0Afrom api.models import Team%0Afrom api.views import TeamViewSet%0A%0A%0Aclass TestTeamsAPI(TestAPICase):%0A    def setUp(self):%0A        super(TestTeamsAPI, self).setUp()%0A        self.view = TeamViewSet.as_view(%7B%0A            'get': 'list',%0A            'post': 'create'%0A        %7D)%0A%0A    def test_teams_list(self):%0A        self._team_create()%0A        request = self.factory.get('/', **self.extra)%0A        response = self.view(request)%0A        owner_team = %7B%0A            'url': 'http://testserver/api/v1/teams/denoinc/1',%0A            'name': u'Owners',%0A            'organization': 'http://testserver/api/v1/users/denoinc',%0A            'projects': %5B%5D%7D%0A        self.assertEqual(response.status_code, 200)%0A        self.assertEqual(response.data, %5Bowner_team, self.team_data%5D)%0A%0A    def test_teams_get(self):%0A        self._team_create()%0A        view = TeamViewSet.as_view(%7B%0A            'get': 'retrieve'%0A        %7D)%0A        request = self.factory.get('/', **self.extra)%0A        response = view(request)%0A        self.assertEqual(response.status_code, 400)%0A        self.assertEqual(response.data,%0A                         %7B'detail':%0A                          'Expected URL keyword argument %60owner%60 and %60pk%60.'%7D)%0A        request = self.factory.get('/', **self.extra)%0A        response = view(request, owner='denoinc', pk=self.team.pk)%0A        self.assertEqual(response.status_code, 200)%0A        self.assertEqual(response.data, self.team_data)%0A%0A    def _team_create(self):%0A        self._org_create()%0A        data = %7B%0A            'name': u'dreamteam',%0A            'organization': self.company_data%5B'user'%5D%0A        %7D%0A        request = self.factory.post(%0A            '/', data=json.dumps(data),%0A            content_type=%22application/json%22, **self.extra)%0A        response = self.view(request, owner='denoinc')%0A        team = Team.objects.get(%0A            organization=self.organization.user,%0A            name='%25s#%25s' %25 (self.organization.user.username, data%5B'name'%5D))%0A        self.assertEqual(response.status_code, 201)%0A        data%5B'url'%5D = 'http://testserver/api/v1/teams/denoinc/%25s' %25 team.pk%0A        self.assertDictContainsSubset(data, response.data)%0A        self.team_data = response.data%0A        self.team = team%0A%0A    def test_teams_create(self):%0A        self._team_create()%0A

test /api/v1/teams