<s> from onadata . apps . main . tests . test_base import TestBase <EOL> from onadata . apps . api import tools <EOL> from onadata . apps . api . models . organization_profile import OrganizationProfile <EOL> from onadata . apps . api . models . team import Team <EOL> from django . core . exceptions import ValidationError <EOL> class TestOrganizationProfile ( TestBase ) : <EOL> def test_create_organization_creates_team_and_perms ( self ) : <EOL> profile = tools . create_organization ( "<STR_LIT>" , self . user ) <EOL> self . assertIsInstance ( profile , OrganizationProfile ) <EOL> organization_profile = OrganizationProfile . objects . get ( <EOL> user__username = "<STR_LIT>" ) <EOL> self . assertTrue ( organization_profile . is_organization ) <EOL> self . assertTrue ( hasattr ( profile , '<STR_LIT>' ) ) <EOL> team_name = "<STR_LIT>" % Team . OWNER_TEAM_NAME <EOL> team = Team . objects . get ( <EOL> organization = organization_profile . user , name = team_name ) <EOL> self . assertIsInstance ( team , Team ) <EOL> self . assertIn ( team . group_ptr , self . user . groups . all ( ) ) <EOL> self . assertTrue ( self . user . has_perm ( '<STR_LIT>' ) ) <EOL> def test_disallow_same_username_with_different_cases ( self ) : <EOL> tools . create_organization ( "<STR_LIT>" , self . user ) <EOL> with self . assertRaises ( ValidationError ) : <EOL> tools . create_organization ( "<STR_LIT>" , self . user ) </s>
