示例#1
0
 def test_slug_generated_from_name(self):
     user = UserFactory()
     request = RequestFactory()
     request.user = user
     form = CustomOrganizationAddForm(request)
     org_name = "This is my org's name!!"
     form.cleaned_data = {'name': org_name}
     org = form.save()
     expected_slug = slugify(org_name)
     self.assertEqual(org.slug, expected_slug)
示例#2
0
 def test_slug_generated_from_name(self):
     user = UserFactory()
     request = RequestFactory()
     request.user = user
     form = CustomOrganizationAddForm(request)
     org_name = "This is my org's name!!"
     form.cleaned_data = {'name': org_name}
     org = form.save()
     expected_slug = slugify(org_name)
     self.assertEqual(org.slug, expected_slug)
示例#3
0
 def test_request_user_is_new_organizations_admin(self):
     """
     We are overriding django-organizations default behavior to find and
     create users based on the requested email and are making the requesting
     user the default admin of a new organization.
     """
     user = UserFactory()
     request = RequestFactory()
     request.user = user
     form = CustomOrganizationAddForm(request)
     form.cleaned_data = {'name': 'Test'}
     org = form.save()
     self.assertTrue(org.is_admin(user))
示例#4
0
 def test_request_user_is_new_organizations_admin(self):
     """
     We are overriding django-organizations' default behavior to find and
     create users based on the requested email and are making the requesting
     user the default admin of a new organization.
     """
     user = UserFactory()
     request = RequestFactory()
     request.user = user
     form = CustomOrganizationAddForm(request)
     form.cleaned_data = {'name': 'Test'}
     org = form.save()
     self.assertTrue(org.is_admin(user))
示例#5
0
 def test_save_assigns_the_edit_decisions_feedback_permission_to_user(self):
     """
     Tests that the permission has been assigned to the user. Also
     implicitly tests that the request.user is the user that is assigned
     to the organization.
     """
     # Note need to set is_active=True otherwise has_perm will be False
     user = UserFactory(is_active=True, email='*****@*****.**')
     request = RequestFactory()
     # With the new save method, the requesting user is the one who gets the
     # new organiations permissions.
     request.user = user
     form = CustomOrganizationAddForm(request)
     form.cleaned_data = {'name': 'Test'}
     org = form.save()
     self.assertTrue(user.has_perm(GUARDIAN_PERMISSION, org))
示例#6
0
 def test_save_assigns_the_edit_decisions_feedback_permission_to_user(self):
     """
     Tests that the permission has been assigned to the user. Also
     implicitly tests that the request.user is the user that is assigned
     to the organization.
     """
     # Note: need to set is_active=True otherwise has_perm will be False
     user = UserFactory(is_active=True, email='*****@*****.**')
     request = RequestFactory()
     # With the new save method, the requesting user is the one who gets the
     # new organization's permissions.
     request.user = user
     form = CustomOrganizationAddForm(request)
     form.cleaned_data = {'name': 'Test'}
     org = form.save()
     self.assertTrue(user.has_perm(GUARDIAN_PERMISSION, org))
示例#7
0
    def test_slug_generated_from_name(self):
        """
        An unique slug should be generated for each Organization from its name.
        """
        org_name = "This is my org's name!!"
        expected_slug = slugify(org_name)

        org1 = OrganizationFactory(name=org_name)
        self.assertEqual(org1.slug, expected_slug)

        user = UserFactory()
        request = RequestFactory()
        request.user = user
        form = CustomOrganizationAddForm(request)
        form.cleaned_data = {'name': org_name}
        org2 = form.save()
        self.assertNotEqual(org2.slug, org1.slug)
        self.assertTrue(org2.slug.startswith(org1.slug))
示例#8
0
    def test_slug_generated_from_name(self):
        """
        An unique slug should be generated for each Organization from its name.
        """
        org_name = "This is my org's name!!"
        expected_slug = slugify(org_name)

        org1 = OrganizationFactory(name=org_name)
        self.assertEqual(org1.slug, expected_slug)

        user = UserFactory()
        request = RequestFactory()
        request.user = user
        form = CustomOrganizationAddForm(request)
        form.cleaned_data = {'name': org_name}
        org2 = form.save()
        self.assertNotEqual(org2.slug, org1.slug)
        self.assertTrue(org2.slug.startswith(org1.slug))
示例#9
0
 def test_excludes_all_fields_except_organization_name(self):
     """
     The form should only ask for the organization's name. 
     """
     form = CustomOrganizationAddForm(RequestFactory())
     self.assertListEqual(form.fields.keys(), ['name'])
示例#10
0
 def test_excludes_all_fields_except_organization_name(self):
     form = CustomOrganizationAddForm(RequestFactory())
     self.assertListEqual(form.fields.keys(), ['name'])