コード例 #1
0
ファイル: db_test.py プロジェクト: juniorsilver/dokomoforms
    def testGetNumberOfSurveys(self):
        number_of_surveys = get_number_of_surveys(connection, 'test_email')
        self.assertEqual(number_of_surveys, 1)

        connection.execute(create_auth_user(email='TestSurveyEmail'))
        zero_surveys = get_number_of_surveys(connection, 'TestSurveyEmail')
        self.assertEqual(zero_surveys, 0)
コード例 #2
0
ファイル: user.py プロジェクト: juniorsilver/dokomoforms
def create_user(connection: Connection, data: dict) -> dict:
    """
    Registers a new user account.

    :param connection: a SQLAlchemy Connection
    :param data: the user's e-mail
    :return: a response containing the e-mail and whether it was created or
    already exists in the database
    """
    email = data['email']
    try:
        get_auth_user_by_email(connection, email)
    except UserDoesNotExistError:
        with connection.begin():
            connection.execute(create_auth_user(email=email))
        return json_response({'email': email, 'response': 'Created'})
    return json_response({'email': email, 'response': 'Already exists'})
コード例 #3
0
ファイル: db_test.py プロジェクト: juniorsilver/dokomoforms
 def testCreateAuthUser(self):
     connection.execute(create_auth_user(email='a'))
     self.assertEqual(len(connection.execute(
         auth_user_table.select().where(
             auth_user_table.c.email == 'a')).fetchall()), 1)