def test_does_not_implode(self): with deepstar_path(): # exist for path in [DBDir.path(), FileDir.path()]: self.assertTrue(os.path.isdir(path)) def mock_input(q): q_ = f'Are you sure you want to implode the deepstar path ' \ f'{os.environ["DEEPSTAR_PATH"]} [y/n]? ' self.assertEqual(q, q_) return 'n' args = ['main.py', 'implode'] opts = {} route_handler = ImplodeCommandLineRouteHandler() try: sys.stdout = StringIO() with mock.patch('builtins.input', side_effect=mock_input): route_handler.handle(args, opts) actual = sys.stdout.getvalue().strip() finally: sys.stdout = sys.__stdout__ # stdout self.assertEqual(actual, 'The deepstar path was not imploded') # files # exist for path in [DBDir.path(), FileDir.path()]: self.assertTrue(os.path.isdir(path))
def path(cls): """ This method returns the path to the transform set directory. :rtype: str """ return os.path.join(FileDir.path(), 'transform_sets')
def path(cls): """ This method returns the path to the frame set directory. :rtype: str """ return os.path.join(FileDir.path(), 'frame_sets')
def path(cls): """ This method returns the path to the video directory. :rtype: str """ return os.path.join(FileDir.path(), 'videos')
def implode(self): """ This method implodes the deepstar path including delete the DB and all files. :rtype: None """ q = f'Are you sure you want to implode the deepstar path ' \ f'{os.environ["DEEPSTAR_PATH"]} [y/n]? ' y = 'The deepstar path was succesfully imploded' n = 'The deepstar path was not imploded' if input(q).strip() == 'y': for path in [DBDir.path(), FileDir.path()]: shutil.rmtree(path) debug(y, 3) else: debug(n, 3)
def test_init(self): with deepstar_path(): FileDir.init() self.assertTrue(os.path.isdir(FileDir.path()))
def test_path(self): with mock.patch.dict(os.environ, {'DEEPSTAR_PATH': 'test'}): self.assertEqual(FileDir.path(), os.path.realpath('test/files'))