obi test: updated to test comments

This commit is contained in:
Celine Mercier
2018-10-07 19:10:46 +02:00
parent e9a41c5b97
commit 9e700ddc21

View File

@ -146,6 +146,18 @@ def random_str_with_max_len(max_len):
def random_bytes_with_max_len(max_len):
return str2bytes(random_str_with_max_len(max_len))
RANDOM_FUNCTIONS = [random_bool, random_char, random_bytes, random_float, random_int]
def random_comments(config):
comments = {}
for i in range(random_length(1000)):
to_add = {random_bytes(config): random.choice(RANDOM_FUNCTIONS)(config)}
if len(str(comments)) + len(str(to_add)) >= COL_COMMENTS_MAX_LEN:
return comments
else:
comments.update(to_add)
return comments
def random_column(infos):
return random.choice(sorted(list(infos['view'].keys())))
@ -305,7 +317,7 @@ def create_random_column(config, infos) :
nb_elements_per_line=nb_elements_per_line,
elements_names=elements_names,
tuples=tuples,
comments=random_str_with_max_len(COL_COMMENTS_MAX_LEN),
comments=random_comments(config),
alias=alias
)
@ -345,15 +357,15 @@ def random_new_view(config, infos, first=False):
v_type = random_view_type()
if line_selection is not None :
infos['view'] = line_selection.materialize(random_unique_name(infos), comments=random_bytes_with_max_len(config['test']['commentsmaxlen']))
infos['view'] = line_selection.materialize(random_unique_name(infos), comments=random_comments(config))
elif v_to_clone is not None :
infos['view'] = v_to_clone.clone(random_unique_name(infos), comments=random_bytes_with_max_len(config['test']['commentsmaxlen']))
infos['view'] = v_to_clone.clone(random_unique_name(infos), comments=random_comments(config))
else :
if v_type == "NUC_SEQS_VIEW" :
infos['view'] = View_NUC_SEQS.new(infos['dms'], random_unique_name(infos), comments=random_bytes_with_max_len(config['test']['commentsmaxlen'])) # TODO quality column
infos['view'] = View_NUC_SEQS.new(infos['dms'], random_unique_name(infos), comments=random_comments(config)) # TODO quality column
else :
infos['view'] = View.new(infos['dms'], random_unique_name(infos), comments=random_bytes_with_max_len(config['test']['commentsmaxlen'])) # TODO quality column
infos['view'] = View.new(infos['dms'], random_unique_name(infos), comments=random_comments(config)) # TODO quality column
print_test(config, repr(infos['view']))
if v_to_clone is not None :
if line_selection is None:
@ -429,15 +441,7 @@ def addOptions(parser):
type=int,
help="Maximum length of tuples. "
"Default: 200")
group.add_argument('--comments_max_len','-c',
action="store", dest="test:commentsmaxlen",
metavar='<COMMENTS_MAX_LEN>',
default=10000,
type=int,
help="Maximum length of view comments. "
"Default: 10000")
group.add_argument('--max_ini_col_count','-o',
action="store", dest="test:maxinicolcount",
metavar='<MAX_INI_COL_COUNT>',
@ -495,6 +499,7 @@ def run(config):
'tests': [test_set_and_get, test_add_col, test_delete_col, test_col_alias, test_new_view]
}
# TODO ???
config['test']['elt_name_max_len'] = int((COL_COMMENTS_MAX_LEN - config['test']['maxelts']) / config['test']['maxelts'])
print("Initializing the DMS and the first view...")