예제 #1
0
    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')
예제 #2
0
    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')
예제 #3
0
파일: tests.py 프로젝트: Fiware/apps.Wstore
    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')
예제 #4
0
파일: tests.py 프로젝트: Fiware/apps.Wstore
    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')