Esempio n. 1
0
    def test_post(self):
        skiplist = SkipList(config=self.config)
        self.assertRaises(MissingArgumentError, skiplist.post)
        self.assertRaises(
            MissingArgumentError,
            skiplist.post,
            category='something'
        )
        self.assertRaises(
            MissingArgumentError,
            skiplist.post,
            rule='something'
        )

        # because of an integrity error since it already exists
        self.assertRaises(
            DatabaseError,
            skiplist.post,
            category='prefix', rule='CrashInJS'
        )

        self.assertTrue(
            skiplist.post(category='suffix', rule='Erik*tiny*font')
        )

        cursor = self.connection.cursor()
        cursor.execute("""
        select * from skiplist where category=%s and rule=%s
        """, ('suffix', 'Erik*tiny*font'))
        first, = cursor.fetchall()
        self.assertEqual(first[0], 'suffix')
        self.assertEqual(first[1], 'Erik*tiny*font')
Esempio n. 2
0
    def test_post(self):
        skiplist = SkipList(config=self.config)
        assert_raises(MissingArgumentError, skiplist.post)
        assert_raises(
            MissingArgumentError,
            skiplist.post,
            category='something'
        )
        assert_raises(
            MissingArgumentError,
            skiplist.post,
            rule='something'
        )

        # because of an integrity error since it already exists
        assert_raises(
            DatabaseError,
            skiplist.post,
            category='prefix', rule='CrashInJS'
        )

        ok_(
            skiplist.post(category='suffix', rule='Erik*tiny*font')
        )

        cursor = self.connection.cursor()
        cursor.execute("""
        select * from skiplist where category=%s and rule=%s
        """, ('suffix', 'Erik*tiny*font'))
        first, = cursor.fetchall()
        eq_(first[0], 'suffix')
        eq_(first[1], 'Erik*tiny*font')