Beispiel #1
0
class UseInviteTestCase(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(username="******", email="*****@*****.**", password="******")
        self.org = Organization(name="Foo Org")
        self.org.save()
        assign_admin_perms(self.org, self.user)
        self.invite = OrganizationInvite(email="*****@*****.**", organization=self.org, user=self.user)
        self.invite.token = get_random_string(length=20, allowed_chars="ABCDEFGHJKMNPQRST23456789")
        self.invite.save()

    def test_use_invite(self):
        url = reverse("use_invite")
        self.client.login(username="******", password="******")
        session = self.client.session
        session["invite"] = self.invite.id
        session.save()
        resp = self.client.get(url)
        invite = OrganizationInvite.objects.get(id=self.invite.id)
        self.assertTrue(invite.is_used)
        self.assertEquals(resp.status_code, 302)

    def test_no_invite(self):
        url = reverse("use_invite")
        self.client.login(username="******", password="******")
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 302)
Beispiel #2
0
class StartInviteTestCase(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(username="******", email="*****@*****.**", password="******")
        self.org = Organization(name="Foo Org")
        self.org.save()
        assign_admin_perms(self.org, self.user)
        self.invite = OrganizationInvite(email="*****@*****.**", organization=self.org, user=self.user)
        self.invite.token = get_random_string(length=20, allowed_chars="ABCDEFGHJKMNPQRST23456789")
        self.invite.save()

    def test_receive_invite(self):
        url = reverse("start_invite", args=(self.invite.id, self.invite.token))
        resp = self.client.get(url)
        self.assertEquals(self.client.session["invite"], self.invite.id)
        self.assertEquals(resp.context["invite_user"], self.user)
        self.assertEquals(resp.context["organization"], self.org)
        self.assertEquals(resp.status_code, 200)

    def test_receive_invite_used(self):
        url = reverse("start_invite", args=(self.invite.id, self.invite.token))
        self.invite.is_used = True
        self.invite.save()
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 404)

    def test_receive_invite_does_not_exist(self):
        url = reverse("start_invite", args=(999, "fake"))
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 404)
Beispiel #3
0
class UseInviteTestCase(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(username='******',
                                             email='*****@*****.**',
                                             password='******')
        self.org = Organization(name='Foo Org')
        self.org.save()
        assign_admin_perms(self.org, self.user)
        self.invite = OrganizationInvite(email='*****@*****.**',
                                         organization=self.org,
                                         user=self.user)
        self.invite.token = get_random_string(
            length=20, allowed_chars='ABCDEFGHJKMNPQRST23456789')
        self.invite.save()

    def test_use_invite(self):
        url = reverse('use_invite')
        self.client.login(username='******', password='******')
        session = self.client.session
        session['invite'] = self.invite.id
        session.save()
        resp = self.client.get(url)
        invite = OrganizationInvite.objects.get(id=self.invite.id)
        self.assertTrue(invite.is_used)
        self.assertEquals(resp.status_code, 302)

    def test_no_invite(self):
        url = reverse('use_invite')
        self.client.login(username='******', password='******')
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 302)
Beispiel #4
0
 def setUp(self):
     self.user = User.objects.create_user(username='******',
                                          email='*****@*****.**',
                                          password='******')
     self.org = Organization(name='Foo Org')
     self.org.save()
     assign_admin_perms(self.org, self.user)
     self.invite = OrganizationInvite(email='*****@*****.**',
                                      organization=self.org,
                                      user=self.user)
     self.invite.token = get_random_string(
         length=20, allowed_chars='ABCDEFGHJKMNPQRST23456789')
     self.invite.save()
Beispiel #5
0
 def setUp(self):
     self.user = User.objects.create_user(username="******", email="*****@*****.**", password="******")
     self.org = Organization(name="Foo Org")
     self.org.save()
     assign_admin_perms(self.org, self.user)
     self.invite = OrganizationInvite(email="*****@*****.**", organization=self.org, user=self.user)
     self.invite.token = get_random_string(length=20, allowed_chars="ABCDEFGHJKMNPQRST23456789")
     self.invite.save()
Beispiel #6
0
class StartInviteTestCase(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(username='******',
                                             email='*****@*****.**',
                                             password='******')
        self.org = Organization(name='Foo Org')
        self.org.save()
        assign_admin_perms(self.org, self.user)
        self.invite = OrganizationInvite(email='*****@*****.**',
                                         organization=self.org,
                                         user=self.user)
        self.invite.token = get_random_string(
            length=20, allowed_chars='ABCDEFGHJKMNPQRST23456789')
        self.invite.save()

    def test_receive_invite(self):
        url = reverse('start_invite',
                      args=(
                          self.invite.id,
                          self.invite.token,
                      ))
        resp = self.client.get(url)
        self.assertEquals(self.client.session['invite'], self.invite.id)
        self.assertEquals(resp.context['invite_user'], self.user)
        self.assertEquals(resp.context['organization'], self.org)
        self.assertEquals(resp.status_code, 200)

    def test_receive_invite_used(self):
        url = reverse('start_invite',
                      args=(
                          self.invite.id,
                          self.invite.token,
                      ))
        self.invite.is_used = True
        self.invite.save()
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 404)

    def test_receive_invite_does_not_exist(self):
        url = reverse('start_invite', args=(
            999,
            'fake',
        ))
        resp = self.client.get(url)
        self.assertEquals(resp.status_code, 404)