Better obi test command
This commit is contained in:
@ -98,22 +98,29 @@ def test_set_and_get(config, infos):
|
||||
if len(element_names) > 1 :
|
||||
elt = random.choice(element_names)
|
||||
col[idx][elt] = value
|
||||
assert col[idx][elt] == value, "Set value != gotten value"
|
||||
assert col[idx][elt] == value, "Set value != gotten value "+str(col[idx][elt])+" != "+str(value)
|
||||
else:
|
||||
col[idx] = value
|
||||
assert col[idx] == value, "Set value != gotten value"
|
||||
assert col[idx] == value, "Set value != gotten value "+str(col[idx])+" != "+str(value)
|
||||
|
||||
print_test(config, ">>> Set and get test OK")
|
||||
|
||||
|
||||
def test_add_col(config, infos):
|
||||
print_test(config, ">>> Add column test")
|
||||
# new_col = random_bool(config)
|
||||
# if new_col : TODO test adding existing column
|
||||
create_random_column(config, infos)
|
||||
#existing_col = random_bool(config) # TODO doesn't work because of line count problem. See obiview.c line 1737
|
||||
#if existing_col and infos["view_names"] != [] :
|
||||
# random_view = infos['dms'].open_view(random.choice(infos["view_names"]))
|
||||
# random_column = random_view[random.choice(list(random_view.get_columns()))]
|
||||
# random_column_refs = random_column.get_references()
|
||||
# if random_column_refs['name'] in infos['view'] :
|
||||
# alias = random_unique_name(infos)
|
||||
# else :
|
||||
# alias = random.choice(['', random_unique_name(infos)])
|
||||
# infos['view'].add_column(column_name, version_number=-1, alias=alias, create=False)
|
||||
# alias = ''
|
||||
# infos['view'].add_column(random_column_refs['name'], version_number=random_column_refs['version'], alias=alias, create=False)
|
||||
# random_view.save_and_close()
|
||||
#else :
|
||||
create_random_column(config, infos)
|
||||
print_test(config, ">>> Add column test OK")
|
||||
|
||||
|
||||
@ -140,12 +147,6 @@ def test_col_alias(config, infos):
|
||||
print_test(config, ">>> Changing column alias test OK")
|
||||
|
||||
|
||||
def test_line_selection(config, infos): # TODO
|
||||
print_test(config, ">>> Selecting line test")
|
||||
infos['view'].select_line(random.randint(0,infos['view'].get_line_count()))
|
||||
print_test(config, ">>> Selecting line test OK")
|
||||
|
||||
|
||||
def test_new_view(config, infos):
|
||||
print_test(config, ">>> New view test")
|
||||
random_new_view(config, infos)
|
||||
@ -211,14 +212,19 @@ def random_new_view(config, infos, first=False):
|
||||
clone = False
|
||||
quality_col = False # TODO
|
||||
if not first:
|
||||
infos['view_names'].append(infos['view'].get_name())
|
||||
infos['view'].save_and_close()
|
||||
v_to_clone = infos['dms'].open_view(random.choice(infos["view_names"]))
|
||||
v_type = None
|
||||
print_test(config, "View to clone: ")
|
||||
print_test(config, repr(v_to_clone))
|
||||
create_line_selection = random_bool(config)
|
||||
if create_line_selection :
|
||||
if create_line_selection and v_to_clone.get_line_count() > 0:
|
||||
print_test(config, "New view with new line selection.")
|
||||
line_selection = []
|
||||
for i in range(random.randint(1, v_to_clone.get_line_count())) :
|
||||
line_selection.append(random.randint(0, v_to_clone.get_line_count()-1))
|
||||
print_test(config, "New line selection: "+str(line_selection))
|
||||
else :
|
||||
v_type = random_view_type()
|
||||
infos['view'] = infos['dms'].new_view(random_unique_name(infos),
|
||||
@ -227,7 +233,12 @@ def random_new_view(config, infos, first=False):
|
||||
view_type=v_type,
|
||||
comments=random_str_with_max_len(config['test']['commentsmaxlen']),
|
||||
quality_column=quality_col)
|
||||
print_test(config, repr(infos['view']))
|
||||
if v_to_clone is not None :
|
||||
if line_selection is None:
|
||||
assert v_to_clone.get_line_count() == infos['view'].get_line_count(), "New view and cloned view don't have the same line count"
|
||||
else :
|
||||
assert len(line_selection) == infos['view'].get_line_count(), "New view with new line selection does not have the right line count"
|
||||
v_to_clone.save_and_close()
|
||||
if first :
|
||||
fill_view(config, infos)
|
||||
@ -241,7 +252,6 @@ def ini_dms_and_first_view(config, infos):
|
||||
create_test_obidms(config, infos)
|
||||
random_new_view(config, infos, first=True)
|
||||
infos['view_names'] = []
|
||||
infos['view_names'].append(infos['view'].get_name())
|
||||
|
||||
|
||||
def addOptions(parser):
|
||||
@ -320,7 +330,7 @@ def run(config):
|
||||
'view_names': None,
|
||||
'unique_names': [],
|
||||
'random_generator': {"OBI_BOOL": random_bool, "OBI_CHAR": random_char, "OBI_FLOAT": random_float, "OBI_INT": random_int, "OBI_SEQ": random_seq, "OBI_STR": random_str},
|
||||
'tests': [test_set_and_get, test_add_col, test_delete_col, test_col_alias] #, test_line_selection] # TODO
|
||||
'tests': [test_set_and_get, test_add_col, test_delete_col, test_col_alias, test_new_view]
|
||||
}
|
||||
|
||||
print("Initializing the DMS and the first view...")
|
||||
@ -330,11 +340,8 @@ def run(config):
|
||||
i = 0
|
||||
for t in range(config['test']['nbtests']):
|
||||
random_test(config, infos)
|
||||
#print(repr(infos['view']))
|
||||
print_test(config, repr(infos['view']))
|
||||
i+=1
|
||||
# New view sometimes but max 100 because of issues with opened files number limit (news views and random modifications = lots of AVL files) TODO test without limit
|
||||
if (i%(config['test']['nbtests']/100)) == 0 :
|
||||
test_new_view(config, infos)
|
||||
if (i%(config['test']['nbtests']/10)) == 0 :
|
||||
print("Testing......"+str(i*100/config['test']['nbtests'])+"%")
|
||||
|
||||
|
Reference in New Issue
Block a user