Added OBIView_line_selection class to make new line selections

associated with the view to clone, and improved and renamed method
closing a view
This commit is contained in:
Celine Mercier
2016-09-30 17:48:53 +02:00
parent d88811ed7d
commit 9cd57deca9
10 changed files with 90 additions and 33 deletions

View File

@ -1,5 +1,6 @@
from obitools3.apps.progress cimport ProgressBar # TODO I absolutely don't understand why it doesn't work without that line
from obitools3.obidms._obidms import OBIDMS # TODO cimport doesn't work
from obitools3.obidms._obidms import OBIView_line_selection
from obitools3.utils cimport str2bytes
import shutil
@ -120,7 +121,7 @@ def test_add_col(config, infos):
# else :
# alias = ''
# infos['view'].add_column(random_column_refs['name'], version_number=random_column_refs['version'], alias=alias, create=False)
# random_view.save_and_close()
# random_view.close()
#else :
create_random_column(config, infos)
print_test(config, ">>> Add column test OK")
@ -215,7 +216,7 @@ def random_new_view(config, infos, first=False):
quality_col = False # TODO
if not first:
infos['view_names'].append(infos['view'].name)
infos['view'].save_and_close()
infos['view'].close()
v_to_clone = infos['dms'].open_view(random.choice(infos["view_names"]))
v_type = None
print_test(config, "View to clone: ")
@ -223,7 +224,7 @@ def random_new_view(config, infos, first=False):
create_line_selection = random_bool(config)
if create_line_selection and v_to_clone.line_count > 0:
print_test(config, "New view with new line selection.")
line_selection = []
line_selection = OBIView_line_selection(v_to_clone)
for i in range(random.randint(1, v_to_clone.line_count)) :
line_selection.append(random.randint(0, v_to_clone.line_count-1))
#print_test(config, "New line selection: "+str(line_selection))
@ -241,7 +242,7 @@ def random_new_view(config, infos, first=False):
assert v_to_clone.line_count == infos['view'].line_count, "New view and cloned view don't have the same line count"
else :
assert len(line_selection) == infos['view'].line_count, "New view with new line selection does not have the right line count"
v_to_clone.save_and_close()
v_to_clone.close()
if first :
fill_view(config, infos)
@ -370,7 +371,7 @@ def run(config):
#print(infos)
infos['view'].save_and_close()
infos['view'].close()
infos['dms'].close()
shutil.rmtree(config['obi']['defaultdms']+'.obidms', ignore_errors=True)