'Tests that byte strings in Python maps to blob type in Cassandra'

def test_can_insert_blob_type_as_string(self):

    s = self.session
    s.execute('CREATE    TABLE    blobstring    (a    ascii    PRIMARY    KEY,    b    blob)')
    params = ['key1', 'blobbyblob']
    query = 'INSERT    INTO    blobstring    (a,    b)    VALUES    (%s,    %s)'
    if (six.PY2 and (self.cql_version >= (3, 1, 0))):
        if (self.cass_version >= (2, 1, 0)):
            msg = '.*Invalid    STRING    constant    \\(.*?\\)    for    "b"    of    type    blob.*'
        else:
            msg = '.*Invalid    STRING    constant    \\(.*?\\)    for    b    of    type    blob.*'
        self.assertRaisesRegexp(InvalidRequest, msg, s.execute, query, params)
        return
    if six.PY2:
        cass_params = [params[0], params[1].encode('hex')]
        s.execute(query, cass_params)
    else:
        s.execute(query, params)
    results = s.execute('SELECT    *    FROM    blobstring')[0]
    for (expected, actual) in zip(params, results):
        self.assertEqual(expected, actual)
