def test_computing_and_saving(self): self._project = Project() self._project.new('Dummy') # Hard import from Tests src_path = Path(str(self.venv_path) + '/Tests/project/Lights') dest_path = Path(str(self._name_path) + '/Lights') shutil.rmtree(dest_path) shutil.copytree(str(src_path), str(dest_path)) src_path = Path(str(self.venv_path) + '/Tests/project/Images') dest_path = Path(str(self._name_path) + '/Images') shutil.rmtree(dest_path) shutil.copytree(str(src_path), str(dest_path)) self._project = None self._project = Project() self._project.open('Dummy') self.segment = self._project.segments['normal'] self.segment.compute() self.assertEqual(str(type(self.segment.content['normals'])), '<class \'numpy.ndarray\'>') self.segment.save() self.assertTrue( 'normals.csv' in os.listdir(self._project.directories['results'])) shutil.rmtree(self._name_path) self._project = None
def test_reading_from_file_when_created(self): self._project = Project() self._project.open('Buddha') self.segment = self._project.segments['light_model'] self.assertEqual(self._test_list, self.segment.content['lights']) self._project = None
def test_making_new_project_with_custom_path(self): if sys.platform == 'linux': self._custom_path = Path('/home/{}/Custom/'.format( getpass.getuser())) if sys.platform == 'win32': self._custom_path = Path('C:\\Users\\{}\\Custom\\'.format( getpass.getuser())) self.project = Project() # Checking what if directory doesnt exist self.assertEqual(None, self.project.new('Dummy', self._custom_path)) # Checking with existing path os.mkdir(self._custom_path) self.project.new('Dummy', self._custom_path) self.assertEqual(self.project.name, 'Dummy') self._check_directories(self._custom_path) # Checking what if new project will be invoked with existing name _copy_of_dummy_project = self.project self.project.new('Dummy', self._custom_path) self.assertEqual(self.project, _copy_of_dummy_project) # Hard delete of project and his directory self.project = None shutil.rmtree(self._custom_path)
def do(*args, **kwargs): """Make new preoject directory and return new project""" name = args[0][0] dir = None if len(args) == 2: dir = args[1][0] project = Project() project.new(name, dir) return project
def test_open_default_project(self): self.project = Project() self.project.new('Dummy') self.project = None self.project = Project() self.project.open('Dummy') self.assertEqual(self.project.name, 'Dummy') self._check_directories(self.venv_path) shutil.rmtree(self._name_path)
def do(*args, **kwargs): """Open existing project""" name = args[0][0] path = None if len(args) == 3: path = args[1][2] project = Project() project.open(name, path) if project.name is None: project = None return project
def test_open__with_custom_path(self): self.project = Project() os.mkdir(self._custom_path) self.project.new('Dummy', self._custom_path) self.project = None self.project = Project() self.project.open("Dummy", self._custom_path) self.assertEqual(self.project.name, 'Dummy') self._check_directories(self._custom_path) shutil.rmtree(self._custom_path)
def test_reading_images(self): self._project = Project() self._project.open('Buddha') self.segment = self._project.segments['light_model'] # Hard cleaning self.segment.content = {'mask': None, 'images': None, 'lights': None} self.segment._read_images() self.assertEqual(str(type(self.segment.content['mask'])), '<class \'numpy.ndarray\'>') self.assertEqual(str(type(self.segment.content['images'])), '<class \'list\'>') for image in self.segment.content['images']: self.assertEqual(str(type(image)), '<class \'numpy.ndarray\'>') self._project = None
def test_save(self): self._project = Project() self._project.new('Dummy') self.segment = self._project.segments['light_model'] _path = Path(str(self.venv_path) + '/Tests/project/test.csv') print(self.segment.content['lights']) self.segment.import_from(str(_path)) self.segment.save() _new_path = Path(str(self._name_path) + '/Lights') self.assertTrue('lights.csv' in os.listdir(str(_new_path))) shutil.rmtree(self._name_path) self._project = None
class TestNormal(unittest.TestCase): def setUp(self): self.venv_path = ROOT_DIR self._name_path = Path(str(self.venv_path) + "/Projects/Dummy") def tearDown(self): try: shutil.rmtree(self._name_path) pass except FileNotFoundError as e: pass def test_computing_and_saving(self): self._project = Project() self._project.new('Dummy') # Hard import from Tests src_path = Path(str(self.venv_path) + '/Tests/project/Lights') dest_path = Path(str(self._name_path) + '/Lights') shutil.rmtree(dest_path) shutil.copytree(str(src_path), str(dest_path)) src_path = Path(str(self.venv_path) + '/Tests/project/Images') dest_path = Path(str(self._name_path) + '/Images') shutil.rmtree(dest_path) shutil.copytree(str(src_path), str(dest_path)) self._project = None self._project = Project() self._project.open('Dummy') self.segment = self._project.segments['normal'] self.segment.compute() self.assertEqual(str(type(self.segment.content['normals'])), '<class \'numpy.ndarray\'>') self.segment.save() self.assertTrue( 'normals.csv' in os.listdir(self._project.directories['results'])) shutil.rmtree(self._name_path) self._project = None '''def reading_from_existing_csv_normals(self):
def test_making_new_project_default(self): self.project = Project() self.project.new('Dummy') self.assertEqual(self.project.name, 'Dummy') self._check_directories(self.venv_path) # Checking what if new project will be invoked whith existing name _copy_of_dummy_project = self.project self.project.new('Dummy') self.assertEqual(self.project, _copy_of_dummy_project) # Hard delete of project and his directory shutil.rmtree(self._name_path) self.project = None
def test_computing(self): self._project = Project() self._project.new('Dummy') self.segment = self._project.segments['light_model'] # Hard import form Tests src_path = Path(str(self.venv_path) + '/Tests/project/Lights') dest_path = Path(str(self._name_path) + '/Lights') os.rmdir(dest_path) shutil.copytree(str(src_path), str(dest_path)) self.segment.compute() print(self.segment.content['lights']) self.assertEqual(str(type(self.segment.content['lights'])), '<class \'list\'>') for image in self.segment.content['images']: self.assertEqual(str(type(image)), '<class \'numpy.ndarray\'>') self._project = None shutil.rmtree(self._name_path)
def test_importing(self): self._project = Project() self._project.new('Dummy') self.segment = self._project.segments['light_model'] self.assertEqual(None, self.segment.content['lights']) # Import OK data set self._test_csv_file('test.csv') # Import NOK data set - less than 3 lines self._test_csv_file('test2.csv') # Import NOK data set - not a float self._test_csv_file('test3.csv') # Import NOK data set - not a 3 dim vector self._test_csv_file('test4.csv') # Import NOK data set - not a .csv file self._test_csv_file('test5.txt') shutil.rmtree(self._name_path) self._project = None
def test_computing_and_saving(self): _project = Project() _project.new('Dummy') # Hard import from Tests src_path = Path(str(self.venv_path) + '/Tests/project/Lights') dest_path = Path(str(self._name_path) + '/Lights') shutil.rmtree(str(dest_path)) shutil.copytree(str(src_path), str(dest_path)) src_path = Path(str(self.venv_path) + '/Tests/project/Images') dest_path = Path(str(self._name_path) + '/Images') shutil.rmtree(str(dest_path)) shutil.copytree(str(src_path), str(dest_path)) src_path = Path(str(self.venv_path) + '/Tests/project/Results') dest_path = Path(str(self._name_path) + '/Results') shutil.rmtree(str(dest_path)) shutil.copytree(str(src_path), str(dest_path)) # Open Dummy again with prepared data _project = Project() _project.open('Dummy') _segment = _project.segments['depth'] #_project.segments['normal'].compute() _segment.compute() self.assertEqual(str(type(_segment.content['depth'])), '<class \'numpy.ndarray\'>') print('zapisuje') _segment.save() print('zapisalem') self.assertTrue('normals.csv' in os.listdir(_project.directories['results'])) shutil.rmtree(self._name_path) self._project = None
class TestLightModel(unittest.TestCase): def setUp(self): self.venv_path = ROOT_DIR self._name_path = Path(str(self.venv_path) + "/Projects/Dummy") self._test_list = [ [0.497239, 0.467590, 0.730831], [0.242239, 0.134516, 0.960846], [-0.039076, 0.174182, 0.983938], [-0.092171, 0.443696, 0.891425], [-0.320376, 0.501764, 0.803488], [-0.110444, 0.560479, 0.820771], [0.281349, 0.424216, 0.860746], [0.100207, 0.430122, 0.897192], [0.206193, 0.333679, 0.919860], [0.086330, 0.331788, 0.939396], [0.128565, 0.044748, 0.990691], [-0.139927, 0.360562, 0.922180]] self._test_list2 = [ # Different set of data [1.237239, 0.467590, 0.730851], [4.2452239, 0.134516, 0.960886], [- 3.049076, 0.134182, 0.983238], [- 0.092171, 0.443696, 0.891425], [- 0.320376, 0.501764, 0.823488], [- 0.130444, 0.560379, 0.825771], [0.281349, 0.424116, 0.860746], [0.102207, 0.430122, 0.895192], [0.306193, 0.333679, 0.919860], [0.086330, 0.331388, 0.939326], [0.528565, 0.044748, 0.990691], [- 0.131927, 0.362562, 0.922980]] def tearDown(self): try: shutil.rmtree(self._name_path) pass except FileNotFoundError as e: pass def test_reading_from_file_when_created(self): self._project = Project() self._project.open('Buddha') self.segment = self._project.segments['light_model'] self.assertEqual(self._test_list, self.segment.content['lights']) self._project = None def test_importing(self): self._project = Project() self._project.new('Dummy') self.segment = self._project.segments['light_model'] self.assertEqual(None, self.segment.content['lights']) # Import OK data set self._test_csv_file('test.csv') # Import NOK data set - less than 3 lines self._test_csv_file('test2.csv') # Import NOK data set - not a float self._test_csv_file('test3.csv') # Import NOK data set - not a 3 dim vector self._test_csv_file('test4.csv') # Import NOK data set - not a .csv file self._test_csv_file('test5.txt') shutil.rmtree(self._name_path) self._project = None def test_reading_images(self): self._project = Project() self._project.open('Buddha') self.segment = self._project.segments['light_model'] # Hard cleaning self.segment.content = {'mask': None, 'images': None, 'lights': None} self.segment._read_images() self.assertEqual(str(type(self.segment.content['mask'])), '<class \'numpy.ndarray\'>') self.assertEqual(str(type(self.segment.content['images'])), '<class \'list\'>') for image in self.segment.content['images']: self.assertEqual(str(type(image)), '<class \'numpy.ndarray\'>') self._project = None def test_computing(self): self._project = Project() self._project.new('Dummy') self.segment = self._project.segments['light_model'] # Hard import form Tests src_path = Path(str(self.venv_path) + '/Tests/project/Lights') dest_path = Path(str(self._name_path) + '/Lights') os.rmdir(dest_path) shutil.copytree(str(src_path), str(dest_path)) self.segment.compute() print(self.segment.content['lights']) self.assertEqual(str(type(self.segment.content['lights'])), '<class \'list\'>') for image in self.segment.content['images']: self.assertEqual(str(type(image)), '<class \'numpy.ndarray\'>') self._project = None shutil.rmtree(self._name_path) def test_save(self): self._project = Project() self._project.new('Dummy') self.segment = self._project.segments['light_model'] _path = Path(str(self.venv_path) + '/Tests/project/test.csv') print(self.segment.content['lights']) self.segment.import_from(str(_path)) self.segment.save() _new_path = Path(str(self._name_path) + '/Lights') self.assertTrue('lights.csv' in os.listdir(str(_new_path))) shutil.rmtree(self._name_path) self._project = None def _test_csv_file(self, file): _path = Path(str(self.venv_path) + '/Tests/project/{}'.format(file)) self.segment.import_from(str(_path)) self.assertEqual(self._test_list2, self.segment.content['lights'])
class TestProject(unittest.TestCase): """Testing the parser class""" def setUp(self): self.venv_path = ROOT_DIR self._name_path = Path(str(self.venv_path) + "/Projects/Dummy") self.project = None if sys.platform == 'linux': self._custom_path = Path('/home/{}/Custom/'.format( getpass.getuser())) if sys.platform == 'win32': self._custom_path = Path('C:\\Users\\{}\\Custom\\'.format( getpass.getuser())) def tearDown(self): try: shutil.rmtree(self._name_path) except FileNotFoundError as e: pass try: shutil.rmtree(self._custom_path) except FileNotFoundError as e: pass def test_making_new_project_default(self): self.project = Project() self.project.new('Dummy') self.assertEqual(self.project.name, 'Dummy') self._check_directories(self.venv_path) # Checking what if new project will be invoked whith existing name _copy_of_dummy_project = self.project self.project.new('Dummy') self.assertEqual(self.project, _copy_of_dummy_project) # Hard delete of project and his directory shutil.rmtree(self._name_path) self.project = None def test_making_new_project_with_custom_path(self): if sys.platform == 'linux': self._custom_path = Path('/home/{}/Custom/'.format( getpass.getuser())) if sys.platform == 'win32': self._custom_path = Path('C:\\Users\\{}\\Custom\\'.format( getpass.getuser())) self.project = Project() # Checking what if directory doesnt exist self.assertEqual(None, self.project.new('Dummy', self._custom_path)) # Checking with existing path os.mkdir(self._custom_path) self.project.new('Dummy', self._custom_path) self.assertEqual(self.project.name, 'Dummy') self._check_directories(self._custom_path) # Checking what if new project will be invoked with existing name _copy_of_dummy_project = self.project self.project.new('Dummy', self._custom_path) self.assertEqual(self.project, _copy_of_dummy_project) # Hard delete of project and his directory self.project = None shutil.rmtree(self._custom_path) def test_open_default_project(self): self.project = Project() self.project.new('Dummy') self.project = None self.project = Project() self.project.open('Dummy') self.assertEqual(self.project.name, 'Dummy') self._check_directories(self.venv_path) shutil.rmtree(self._name_path) def test_open__with_custom_path(self): self.project = Project() os.mkdir(self._custom_path) self.project.new('Dummy', self._custom_path) self.project = None self.project = Project() self.project.open("Dummy", self._custom_path) self.assertEqual(self.project.name, 'Dummy') self._check_directories(self._custom_path) shutil.rmtree(self._custom_path) def _check_directories(self, dir): self.assertEqual(self.project.directories['home'], dir) _projects_path = Path(str(dir) + "/Projects") self.assertEqual(self.project.directories['projects'], _projects_path) _name_path = Path(str(dir) + "/Projects/Dummy") self.assertEqual(self.project.directories['name'], _name_path) _images_path = Path(str(dir) + "/Projects/Dummy/Images") self.assertEqual(self.project.directories['images'], _images_path) _results_path = Path(str(dir) + "/Projects/Dummy/Results") self.assertEqual(self.project.directories['results'], _results_path) _config_path = Path(str(dir) + "/Projects/Dummy/config.txt") self.assertEqual(self.project.directories['config'], _config_path)