def test_set_project(): state.set_project('fixture/prj_3file_I/') def fpath(*ps): return str(Path(*ps)) assert state.img_paths == ( fpath('fixture/prj_3file_I',config.IMGDIR,'1'), fpath('fixture/prj_3file_I',config.IMGDIR,'2.png'), fpath('fixture/prj_3file_I',config.IMGDIR,'3.jpg') ) assert state.mask_paths == ( fpath('fixture/prj_3file_I',config.MASKDIR,'1.png'), fpath('fixture/prj_3file_I',config.MASKDIR,'2.png'), fpath('fixture/prj_3file_I',config.MASKDIR,'3.png') )
def test_img_mask_pairs(): state.set_project('fixture/prj_3file_I/') img_masks = state.img_mask_pairs() expected_pairs = [ (fpath('fixture/prj_3file_I', consts.IMGDIR, '1'), fpath('fixture/prj_3file_I', consts.MASKDIR, '1.png')), (fpath('fixture/prj_3file_I', consts.IMGDIR, '2.png'), fpath('fixture/prj_3file_I', consts.MASKDIR, '2.png')), (fpath('fixture/prj_3file_I', consts.IMGDIR, '3.jpg'), fpath('fixture/prj_3file_I', consts.MASKDIR, '3.png')), ] for actual, (ipath, mpath) in zip(state.img_mask_pairs(), expected_pairs): assert actual.img == ipath assert actual.mask == mpath
def open_project(self, dir_url): dirpath = dir_url.toLocalFile() dir_type = state.dir_type(dirpath) if dir_type == config.UNSUPPORT_DIR: self.warning.emit(config.WARN_MSGS[config.UNSUPPORT_DIR]) return dir_type # for test if dir_type == config.FLAT_IMGDIR: #TODO: create project directory structure # and then copy images into 'images' # and then reset dirpath # and then below: use project directory self.warning.emit(config.WARN_MSGS[config.FLAT_IMGDIR]) else: self.initialize.emit() state.set_project(dirpath) self.update_gui() return dir_type
def test_set_project_kor_path(): prjdir = 'fixture/한국어경로3img/' state.set_project(prjdir) assert state.img_paths == (fpath(prjdir, consts.IMGDIR, '1'), fpath(prjdir, consts.IMGDIR, '2.png'), fpath(prjdir, consts.IMGDIR, '3.jpg')) assert state.mask_paths == (fpath(prjdir, consts.MASKDIR, '1.png'), fpath(prjdir, consts.MASKDIR, '2.png'), fpath(prjdir, consts.MASKDIR, '3.png')) assert state.prev_img_paths == (fpath_real(prjdir, consts.PREV_IMGDIR, '1'), fpath_real(prjdir, consts.PREV_IMGDIR, '2.png'), fpath_real(prjdir, consts.PREV_IMGDIR, '3.jpg')) assert state.prev_mask_paths == (fpath_real(prjdir, consts.PREV_MASKDIR, '1.png'), fpath_real(prjdir, consts.PREV_MASKDIR, '2.png'), fpath_real(prjdir, consts.PREV_MASKDIR, '3.png'))
def set_project(self, dirpath): self.initialize.emit() state.set_project(dirpath) self.update_gui()
def test_clear_all(): state.set_project('fixture/prj_3file_I/') state.clear_all() assert state.project() == ((), ()) assert state.cursor() == 0
def test_load_only_image_files(tmpdir): imgdir = './private_fixtures/broken_imghdr_partial/' state.new_project(imgdir, tmpdir) state.set_project(tmpdir) assert len(state.img_paths) == 3 # dependent to fixture..