<s> from __future__ import absolute_import <EOL> from django . core . urlresolvers import reverse <EOL> from exam import fixture <EOL> from sentry . models import Project , ProjectStatus <EOL> from sentry . testutils import APITestCase <EOL> class ProjectsListTest ( APITestCase ) : <EOL> @ fixture <EOL> def path ( self ) : <EOL> return reverse ( '<STR_LIT>' ) <EOL> def test_member ( self ) : <EOL> user = self . create_user ( '<STR_LIT>' , is_superuser = False ) <EOL> org = self . create_organization ( name = '<STR_LIT:foo>' ) <EOL> team = self . create_team ( organization = org , name = '<STR_LIT:foo>' ) <EOL> project = self . create_project ( team = team , organization = org ) <EOL> self . create_member ( organization = org , user = user , teams = [ team ] ) <EOL> org2 = self . create_organization ( name = '<STR_LIT:bar>' ) <EOL> team2 = self . create_team ( organization = org , name = '<STR_LIT:bar>' ) <EOL> self . create_project ( team = team2 , organization = org2 ) <EOL> self . login_as ( user = user ) <EOL> response = self . client . get ( self . path ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( project . id ) <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] == str ( org . id ) <EOL> def test_superuser ( self ) : <EOL> Project . objects . all ( ) . delete ( ) <EOL> user = self . create_user ( '<STR_LIT>' , is_superuser = True ) <EOL> org = self . create_organization ( name = '<STR_LIT:foo>' , owner = user ) <EOL> self . create_project ( organization = org ) <EOL> org2 = self . create_organization ( name = '<STR_LIT:bar>' ) <EOL> self . create_project ( organization = org2 ) <EOL> self . login_as ( user = user ) <EOL> response = self . client . get ( self . path ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:2> <EOL> def test_status_filter ( self ) : <EOL> Project . objects . all ( ) . delete ( ) <EOL> user = self . create_user ( '<STR_LIT>' , is_superuser = True ) <EOL> org = self . create_organization ( name = '<STR_LIT:foo>' ) <EOL> project1 = self . create_project ( organization = org ) <EOL> org2 = self . create_organization ( name = '<STR_LIT:bar>' ) <EOL> project2 = self . create_project ( organization = org2 , status = ProjectStatus . PENDING_DELETION ) <EOL> self . login_as ( user = user ) <EOL> response = self . client . get ( self . path + '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( project1 . id ) <EOL> response = self . client . get ( self . path + '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( project2 . id ) <EOL> def test_query_filter ( self ) : <EOL> Project . objects . all ( ) . delete ( ) <EOL> user = self . create_user ( '<STR_LIT>' , is_superuser = True ) <EOL> org = self . create_organization ( name = '<STR_LIT:foo>' ) <EOL> project1 = self . create_project ( name = '<STR_LIT:foo>' , organization = org ) <EOL> org2 = self . create_organization ( name = '<STR_LIT:bar>' ) <EOL> self . create_project ( name = '<STR_LIT:bar>' , organization = org2 ) <EOL> self . login_as ( user = user ) <EOL> response = self . client . get ( self . path + '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:1> <EOL> assert response . data [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] == str ( project1 . id ) <EOL> response = self . client . get ( self . path + '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert len ( response . data ) == <NUM_LIT:0> </s>
