Esempio n. 1
0
    def sign_up(request, email, password, first_name, last_name):
        """
        Creates an account and signs the user in.
        """

        UserService.create(email, password, first_name, last_name)
        return IdentityService.sign_in(request, email, password)
Esempio n. 2
0
    def test_cannot_create_with_taken_email(self):
        """
        If an email is in use by another user when signing up, it should throw
        an error.
        """
        email = "*****@*****.**"

        UserService.create(email, "-", "-", "-")

        with self.assertRaises(
                BadRequestException,
                msg="The email {} is already in use".format(email)):
            UserService.create(email, "-", "-", "-")
Esempio n. 3
0
    def test_create(self):
        """
        A user can be created.
        """
        email = "*****@*****.**"
        password = "******"
        first_name = "John"
        last_name = "Doe"
        user = UserService.create(email, password, first_name, last_name)

        self.assertNotEqual(user, None)
        self.assertEqual(user.email, email)
        self.assertEqual(user.first_name, first_name)
        self.assertEqual(user.last_name, last_name)
Esempio n. 4
0
    def test_cannot_create_with_empty_fields(self):
        """
        All fields must be non-empty strings, otherwise the user creation
        should fail.
        """
        email = "*****@*****.**"
        password = "******"
        first_name = "John"
        last_name = "Doe"

        with self.assertRaises(BadRequestException,
                               msg="An email must be supplied"):
            UserService.create("", password, first_name, last_name)
        with self.assertRaises(BadRequestException,
                               msg="A password must be supplied"):
            UserService.create(email, "", first_name, last_name)
        with self.assertRaises(BadRequestException,
                               msg="A first name must be supplied"):
            UserService.create(email, password, "", last_name)
        with self.assertRaises(BadRequestException,
                               msg="A last name must be supplied"):
            UserService.create(email, password, first_name, "")
Esempio n. 5
0
 def setUp(self):
     self.user = UserService.create("*****@*****.**", "hunter2", "John",
                                    "Doe")
 def setUp(self):
     self.user = UserService.create("*****@*****.**", "hunter2", "John",
                                    "Doe")
     self.team = TeamService.create_team_with_user_as_owner(
         self.user, "John's team", "")
     self.meeting = MeetingService.create(self.team.id, "A meeting")