Esempio n. 1
0
 def test_can_validate_a_basic_membership_token(self):
     # Setup
     form_data = {
         'email': faker.email(),
         'first_name': faker.first_name(),
         'last_name': faker.last_name(),
     }
     form = OrganisationMembershipTokenCreateForm(form_data, organisation=self.organisation)
     # Run & check
     self.assertTrue(form.is_valid())
Esempio n. 2
0
 def test_cannot_validate_if_the_email_is_already_used_by_a_member_of_the_organisation(self):
     # Setup
     self.organisation.members.add(self.user)
     form_data = {
         'email': self.user.email,
         'first_name': faker.first_name(),
         'last_name': faker.last_name(),
     }
     form = OrganisationMembershipTokenCreateForm(form_data, organisation=self.organisation)
     # Run & check
     self.assertFalse(form.is_valid())
     self.assertTrue('email' in form.errors)
Esempio n. 3
0
 def test_cannot_validate_if_the_email_is_already_used_by_another_token(self):
     # Setup
     AccountActionTokenFactory.create(
         action=OrganisationMembershipAction.name, content_object=self.organisation,
         email='*****@*****.**')
     form_data = {
         'email': '*****@*****.**',
         'first_name': faker.first_name(),
         'last_name': faker.last_name(),
     }
     form = OrganisationMembershipTokenCreateForm(form_data, organisation=self.organisation)
     # Run & check
     self.assertFalse(form.is_valid())
     self.assertTrue('email' in form.errors)
Esempio n. 4
0
 def test_can_properly_create_a_membership_token(self):
     # Setup
     form_data = {
         'email': faker.email(),
         'first_name': faker.first_name(),
         'last_name': faker.last_name(),
     }
     form = OrganisationMembershipTokenCreateForm(form_data, organisation=self.organisation)
     # Run & check
     self.assertTrue(form.is_valid())
     form.save()
     token = AccountActionToken.objects.first()
     self.assertEqual(token.email, form_data['email'])
     self.assertEqual(token.first_name, form_data['first_name'])
     self.assertEqual(token.last_name, form_data['last_name'])
     self.assertEqual(token.action, OrganisationMembershipAction.name)
     self.assertTrue(token.can_be_consumed)