def test_iden_unique(self):
     q_str = Query.into(self.idens).columns(self.idens.identifier).insert(
         Parameter('%s')).get_sql()
     q_args = ('iden', )
     self.cursor.execute(q_str, q_args)
     helper.assert_fails_with_pgcode(self, '23505', self.cursor, q_str,
                                     q_args)
 def test_appname_unique(self):
     q_str = Query.into(self.apps).columns(self.apps.name).insert(
         Parameter('%s')).get_sql()
     q_args = ('appnm', )
     self.cursor.execute(q_str, q_args)
     helper.assert_fails_with_pgcode(self, '23505', self.cursor, q_str,
                                     q_args)
Ejemplo n.º 3
0
 def test_fullname_uniqueness(self):
     hfullnms = Table('handled_fullnames')
     q_str = Query.into(hfullnms).columns('fullname').insert(
         Parameter('%s')).get_sql()
     q_args = ('t1_test', )
     self.cursor.execute(q_str, q_args)
     helper.assert_fails_with_pgcode(self, '23505', self.cursor, q_str,
                                     q_args)
Ejemplo n.º 4
0
 def test_uname_uniqueness(self):
     users = Table('users')
     q_str = Query.into(users).columns('username').insert(
         Parameter('%s')).get_sql()
     q_args = ('test-user', )
     self.cursor.execute(q_str, q_args)
     helper.assert_fails_with_pgcode(self, '23505', self.cursor, q_str,
                                     q_args)
 def test_responses_unique_name(self):
     responses = Table('responses')
     q_str = Query.into(responses).columns(
         responses.name, responses.response_body
     ).insert(Parameter('%s'), Parameter('%s')).get_sql()
     self.cursor.execute(q_str, ('test_nm', 'Test body'))
     helper.assert_fails_with_pgcode(
         self, '23505', self.cursor, q_str, ('test_nm', 'Test body 2')
     )
 def test_event_requires_appid(self):
     self.cursor.execute(
         Query.into(self.idens).columns(self.idens.identifier).insert(
             Parameter('%s')).returning(self.idens.id).get_sql(),
         ('iden', ))
     iden_id = self.cursor.fetchone()[0]
     helper.assert_fails_with_pgcode(
         self, '23502', self.cursor,
         Query.into(self.events).columns(
             self.events.level, self.events.identifier_id,
             self.events.message).insert(
                 *[Parameter('%s') for _ in range(3)]).get_sql(),
         (1, iden_id, 'my message'))
    def test_allows_exactly_one_human(self):
        self.cursor.execute(
            'INSERT INTO users (username) VALUES (%s) RETURNING id', ('foo',)
        )
        (user_id,) = self.cursor.fetchone()

        q_str = (
            'INSERT INTO password_authentications ' +
            '(user_id, human, hash_name, hash, salt, iterations) ' +
            'VALUES (%s, %s, %s, %s, %s, %s)'
        )
        q_args = (user_id, True, 'foo', 'foo', 'foo', 10)
        self.cursor.execute(q_str, q_args)
        q_args = (user_id, True, 'foo', 'foo2', 'foo2', 10)
        helper.assert_fails_with_pgcode(
            self, '23505', self.cursor, q_str, q_args)