def test_organization_change_errors(self): errors = ['Not found', 'Forbidden'] for i in [0, 1]: if i == 1: Organization.objects.create(name='test_org') response = views.change_current_organization(self.request) body_response = json.loads(response.content) self.assertEquals(body_response['message'], errors[i]) self.assertEquals(body_response['result'], 'error')
def test_organization_change(self): org = Organization.objects.create(name='test_org') # Update user profile info self.user.userprofile.organizations.append({'organization': org.pk}) self.user.userprofile.save() response = views.change_current_organization(self.request) self.user = User.objects.get(username='******') self.assertEquals(self.user.userprofile.current_organization.pk, org.pk) body_response = json.loads(response.content) self.assertEquals(response.status_code, 200) self.assertEquals(body_response['message'], 'OK') self.assertEquals(body_response['result'], 'correct')
def test_organization_change_errors(self): errors = [ 'Not found', 'Forbidden' ] for i in [0, 1]: if i == 1: Organization.objects.create( name='test_org' ) response = views.change_current_organization(self.request) body_response = json.loads(response.content) self.assertEquals(body_response['message'], errors[i]) self.assertEquals(body_response['result'], 'error')
def test_organization_change(self): org = Organization.objects.create( name='test_org' ) # Update user profile info self.user.userprofile.organizations.append({ 'organization': org.pk }) self.user.userprofile.save() response = views.change_current_organization(self.request) self.user = User.objects.get(username='******') self.assertEquals(self.user.userprofile.current_organization.pk, org.pk) body_response = json.loads(response.content) self.assertEquals(response.status_code, 200) self.assertEquals(body_response['message'], 'OK') self.assertEquals(body_response['result'], 'correct')