Exemplo n.º 1
0
 def test_second_registration(self):
     """Test register if user is registered already"""
     UserFactory.create(
         email="*****@*****.**",
         password="******",
     )
     response = self.client.post(
         reverse('register'),
         json.dumps({
             "email": "*****@*****.**",
             "password": "******"
         }),
         content_type='application/json'
     )
     self.assertEqual(response.status_code, 201)
Exemplo n.º 2
0
    def test_get(self):
        for _ in range(5):
            UserFactory.create()

        admin_emails = sorted(
            UserFactory.create(userprofile__is_administrator=True).email
            for _ in range(2))

        res = self.client.get(ENDPOINT_URL)

        self.assertDictEqual(
            res.data, {
                'administrator_emails': admin_emails,
                'applicant_types': ContactSerializer.APPLICANT_CHOICES,
            })
Exemplo n.º 3
0
    def test_does_not_raise_error_if_user_is_admin(self):
        user = UserFactory.create(userprofile__is_administrator=True)

        try:
            validate_admin_email(user.email)
        except ValidationError:
            self.fail('raised error when user is admin')
Exemplo n.º 4
0
    def setUp(self):
        """Set up test for OfferFactory"""

        self.fake_user1 = UserFactory.create(
            first_name="Fake user first_name1",
            last_name="Fake user last_name1")
        self.fake_user2 = UserFactory.create(
            first_name="Fake user first_name2",
            last_name="Fake user last_name2")
        self.fake_offer1 = OfferFactory.create(volunteers=User.objects.all())
        self.fake_offer2 = OfferFactory.create(
            title="Jakiś tytuł",
            description="Zwięzły opis",
            organization__name="Nazwa odnośnej organizacji")
        self.fake_offer3 = OfferFactory.create(
            organization=Organization.objects.last())
Exemplo n.º 5
0
 def setUp(self):
     """Set up each test."""
     super(TestAuthenticatedUserJoinOffer, self).setUp()
     self.user = UserFactory.create()
     self.offer = OfferFactory.create()
     self.offer.publish()
     self.client.force_login(self.user)
Exemplo n.º 6
0
    def test_raises_error_if_user_is_not_admin(self):
        user = UserFactory.create(userprofile__is_administrator=False)

        with self.assertRaises(
                ValidationError,
                msg='Administrator o adresie e-mail {} nie istnieje.'.format(
                    user.email, ),
        ):
            validate_admin_email(user.email)
Exemplo n.º 7
0
    def test_login(self):
        user = UserFactory.create(password='******')
        organization = OrganizationFactory.create()
        organization.userprofiles = [user.userprofile]
        organization.save()

        res = self.client.post(ENDPOINT_URL, {
            'username': user.username,
            'password': '******'
        }, format='json')

        self.assertEqual(res.status_code, 200)
Exemplo n.º 8
0
 def setUp(self):
     """setting up each test."""
     UserFactory.create(first_name="nie-Jan", last_name="nie-Kowalski")
     self.totally_fake_user = UserFactory.create()
Exemplo n.º 9
0
 def setUp(self):
     """ Set up for each test """
     self.user = UserFactory.create()
     self.uid = str(urlsafe_base64_encode(force_bytes(self.user.pk)),
                    'utf-8')
     self.token = default_token_generator.make_token(self.user)
Exemplo n.º 10
0
 def setUpClass(cls):
     super().setUpClass()
     cls.admin = UserFactory.create(userprofile__is_administrator=True)
Exemplo n.º 11
0
 def setUpClass(cls):
     cls.user = UserFactory.create()
Exemplo n.º 12
0
 def setUpClass(cls):
     super().setUpClass()
     cls.password = '******'
     cls.user = UserFactory.create()  # type: User
     cls.user.set_password(cls.password)
     cls.user.save()