Exemplo n.º 1
0
    def test_raise_error_if_email_is_already_taken(self):
        """
        Verifies that if the email provided belongs to a user that is not
        signed in, an error is raised from user_creation_retrieval

        """
        UserFactory(email="*****@*****.**")
        with self.assertRaises(ValueError, msg="ValueError should have raised!"
                                               " Email provided was in use."):
           user_creation_retrieval(self.user, "*****@*****.**")
Exemplo n.º 2
0
    def test_raise_error_if_email_is_already_taken(self):
        """
        Verifies that if the email provided belongs to a user that is not
        signed in, an error is raised from user_creation_retrieval

        """
        UserFactory(email="*****@*****.**")
        with self.assertRaises(ValueError,
                               msg="ValueError should have raised!"
                               " Email provided was in use."):
            user_creation_retrieval(self.user, "*****@*****.**")
Exemplo n.º 3
0
    def test_user_retrieved_parameters_required(self):
        """
        Verifies that user_creation_retrieval only works if both auth user and
        email are provided to user_creation_retrieval

        """
        with self.assertRaises(ValueError,
                               msg="Error not thrown when email empty"):
            user_creation_retrieval(self.user, "")

        with self.assertRaises(ValueError,
                               msg="Error not thrown when user is none"):
            user_creation_retrieval(None, "*****@*****.**")
Exemplo n.º 4
0
    def test_user_retrieved_parameters_required(self):
        """
        Verifies that user_creation_retrieval only works if both auth user and
        email are provided to user_creation_retrieval

        """
        with self.assertRaises(ValueError,
                               msg="Error not thrown when email empty"):
            user_creation_retrieval(self.user, "")

        with self.assertRaises(ValueError,
                               msg="Error not thrown when user is none"):
            user_creation_retrieval(None, "*****@*****.**")
Exemplo n.º 5
0
    def test_return_user_if_email_not_taken(self):
        """
        Verifies that if an unused email is provided, a user is created for
        that user and it is returned by user_creation_retrieval

        """
        user_account, created = user_creation_retrieval(self.user,
                                                        "*****@*****.**")
        self.assertTrue(created)
        self.assertNotEqual(self.user, user_account,
                         msg="Original user was retrieved. Should have created"
                             " a new user.")
Exemplo n.º 6
0
    def test_return_user_if_exists_and_is_logged_in(self):
        """
        Verifies that if the email provided belongs to the authenticated user,
        that user's account is returned from user_creation_retrieval

        """
        user_account, created = user_creation_retrieval(self.user,
                                                        self.user.email)
        self.assertFalse(created)
        self.assertEqual(self.user, user_account,
                         msg="User retrieved did not match authenticated"
                             " user.")
Exemplo n.º 7
0
    def test_return_user_if_exists_and_is_logged_in(self):
        """
        Verifies that if the email provided belongs to the authenticated user,
        that user's account is returned from user_creation_retrieval

        """
        user_account, created = user_creation_retrieval(
            self.user, self.user.email)
        self.assertFalse(created)
        self.assertEqual(self.user,
                         user_account,
                         msg="User retrieved did not match authenticated"
                         " user.")
Exemplo n.º 8
0
    def test_return_user_if_email_not_taken(self):
        """
        Verifies that if an unused email is provided, a user is created for
        that user and it is returned by user_creation_retrieval

        """
        user_account, created = user_creation_retrieval(
            self.user, "*****@*****.**")
        self.assertTrue(created)
        self.assertNotEqual(
            self.user,
            user_account,
            msg="Original user was retrieved. Should have created"
            " a new user.")