'Test to validate that the numpy protocol handler can deal with null values.
@since 3.3.0
- updated 3.6.0: now numeric types used masked array
@jira_ticket PYTHON-550
@expected_result Numpy can handle non mapped types\' null values.
@test_category data_types:serialization'

@numpytest
@greaterthancass21
def test_null_types(self):

    s = self.session
    s.row_factory = tuple_factory
    s.client_protocol_handler = NumpyProtocolHandler
    table = ('%s.%s' % (self.keyspace_name, self.function_table_name))
    create_table_with_all_types(table, s, 10)
    begin_unset = (max(s.execute(('select    primkey    from    %s' % (table,)))[0]['primkey']) + 1)
    keys_null = range(begin_unset, (begin_unset + 10))
    insert = ('insert    into    %s    (primkey)    values    (%%s)' % (table,))
    execute_concurrent_with_args(s, insert, ((k,) for k in keys_null))
    result = s.execute(('select    *    from    %s' % (table,)))[0]
    from numpy.ma import masked, MaskedArray
    result_keys = result.pop('primkey')
    mapped_index = [v[1] for v in sorted(zip(result_keys, count()))]
    had_masked = had_none = False
    for col_array in result.values():
        if isinstance(col_array, MaskedArray):
            had_masked = True
            [self.assertIsNot(col_array[i], masked) for i in mapped_index[:begin_unset]]
            [self.assertIs(col_array[i], masked) for i in mapped_index[begin_unset:]]
        else:
            had_none = True
            [self.assertIsNotNone(col_array[i]) for i in mapped_index[:begin_unset]]
            [self.assertIsNone(col_array[i]) for i in mapped_index[begin_unset:]]
    self.assertTrue(had_masked)
    self.assertTrue(had_none)
